### Basic usage of hahoorequest with Promises Source: https://github.com/hahoocn/hahoorequest/blob/master/README.md Demonstrates how to make a GET request using hahoorequest, which returns a Promise. The example shows how to configure the request with URL, method, and type, and how to handle the successful response using a .then() callback. ```JavaScript request({ url: 'https://raw.githubusercontent.com/hahoocn/hahoorequest/master/test/test.json', method: 'GET', type: 'json' }) .then((res) => { console.log(res.body); }); ``` -------------------------------- ### Install hahoorequest via npm Source: https://github.com/hahoocn/hahoorequest/blob/master/README.md Instructions to install the hahoorequest library using the Node Package Manager (npm). This command adds the package as a dependency to your project. ```Shell npm install hahoorequest --save ``` -------------------------------- ### Import hahoorequest for isomorphic environments Source: https://github.com/hahoocn/hahoorequest/blob/master/README.md Examples of importing the hahoorequest library, configured for different underlying HTTP client combinations across browser and server environments to support isomorphic applications. ```JavaScript import request from 'hahoorequest/lib/fetch'; ``` ```JavaScript import request from 'hahoorequest/lib/fetch-request'; ``` ```JavaScript import request from 'hahoorequest/lib/reqwest-fetch'; ``` ```JavaScript import request from 'hahoorequest/lib/reqwest-request'; ``` ```JavaScript import request from 'hahoorequest/lib/superagent'; ``` ```JavaScript import request from 'hahoorequest/lib/superagent-fetch'; ``` ```JavaScript import request from 'hahoorequest/lib/superagent-request'; ``` -------------------------------- ### Import hahoorequest for server-only environments Source: https://github.com/hahoocn/hahoorequest/blob/master/README.md Examples of importing the hahoorequest library, configured for specific server-side HTTP clients like node-fetch or the 'request' library. ```JavaScript import request from 'hahoorequest/lib/node-fetch'; ``` ```JavaScript import request from 'hahoorequest/lib/node-request'; ``` -------------------------------- ### Import hahoorequest for browser-only environments Source: https://github.com/hahoocn/hahoorequest/blob/master/README.md Examples of importing the hahoorequest library, configured for specific browser-side HTTP clients like fetch, reqwest, or superagent. ```JavaScript import request from 'hahoorequest/lib/whatwg-fetch'; ``` ```JavaScript import request from 'hahoorequest/lib/reqwest'; ``` ```JavaScript import request from 'hahoorequest/lib/superagent'; ``` -------------------------------- ### hahoorequest Request Options API Source: https://github.com/hahoocn/hahoorequest/blob/master/README.md Defines the configurable options available when making a request with hahoorequest. These options allow control over the URL, HTTP method, headers, request body, response type, query parameters, and credential handling. ```APIDOC RequestOptions: url: string - a fully qualified uri method: string - http method (default: 'GET') headers: object - http headers body: string | object - entity body for PATCH, POST and PUT requests. Must be a query String or JSON object type: string - a string enum. html, xml, json, form, png... (default: 'json') qs: object - object containing querystring values to be appended to the url credentials: any - Sending cookies. fetch set credentials option. if credentials is not undefined, reqwest and superagent will add withCredentials = true ``` -------------------------------- ### hahoorequest Response Object API Source: https://github.com/hahoocn/hahoorequest/blob/master/README.md Describes the structure of the response object returned by hahoorequest upon a successful HTTP request. It includes properties for the response body and HTTP status code. ```APIDOC ResponseObject: response.body: any - Content of response response.status: number - http status code ``` -------------------------------- ### hahoorequest Error Object API Source: https://github.com/hahoocn/hahoorequest/blob/master/README.md Describes the structure of the error object returned by hahoorequest in case of a request failure. It provides properties for an error code and a descriptive error message. ```APIDOC ErrorObject: response.errcode: string | number - Code of errors response.errmsg: string - Content of errors ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.