### Install tiny-json-http Source: https://github.com/brianleroux/tiny-json-http/blob/main/readme.md Installs the tiny-json-http package using npm. This is the primary method for adding the library to your project. ```bash npm i tiny-json-http --save ``` -------------------------------- ### Example: Async/Await Usage Source: https://github.com/brianleroux/tiny-json-http/blob/main/readme.md Demonstrates how to use tiny-json-http with async/await for making HTTP requests. It shows a typical pattern for handling successful responses and errors. ```javascript var tiny = require('tiny-json-http') var url = 'http://www.randomkittengenerator.com' ;(async function _iife() { try { console.log(await tiny.get({url})) } catch (err) { console.log('ruh roh!', err) } })(); ``` -------------------------------- ### Example: Callback Usage Source: https://github.com/brianleroux/tiny-json-http/blob/main/readme.md Illustrates how to use tiny-json-http with a traditional Node.js style callback. This example shows how to handle potential errors and process the result. ```javascript var tiny = require('tiny-json-http') var url = 'http://www.randomkittengenerator.com' tiny.get({url}, function _get(err, result) { if (err) { console.log('ruh roh!', err) } else { console.log(result) } }) ``` -------------------------------- ### tiny-json-http API Documentation Source: https://github.com/brianleroux/tiny-json-http/blob/main/readme.md Provides an overview of the available methods in the tiny-json-http library, categorized into read and write operations. It also details the callback values and Promise behavior. ```APIDOC tiny-json-http API: Read methods: - tiny.get(options[, callback]): Performs an HTTP GET request. - tiny.head(options[, callback]): Performs an HTTP HEAD request. - tiny.options(options[, callback]): Performs an HTTP OPTIONS request. Write methods: - tiny.post(options[, callback]): Performs an HTTP POST request. - tiny.put(options[, callback]): Performs an HTTP PUT request. - tiny.patch(options[, callback]): Performs an HTTP PATCH request. - tiny.del(options[, callback]): Performs an HTTP DELETE request. Note: The callback parameter is optional. If not provided, the methods return a Promise. Options: - url: Required. The URL for the HTTP request. - data: Form variables for POST, PUT, PATCH, DELETE. Querystring variables for GET. - headers: Key/value map for request headers, including multipart/form-data support. - buffer: If true, the response body is returned as a buffer. Callback values: - err: A JavaScript Error object if an error occurred. - data: An object containing 'headers' and 'body' keys. Promises: - Methods return a Promise if no callback is supplied, suitable for async/await. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.