httpGet

Classes

httpGetRequest

Methods

(static) ahttpGet(uri, paramsopt) → {object}

Description:
  • Async/await version of httpGet, never rejects meaning no exceptions

Parameters:
Name Type Attributes Description
uri string

can be full URL or an object with parts of the url, same format as in url.format

params httpGetRequest <optional>

customize request

Returns:
Type Description
object
  • result as an object { err, data, obj, req } where data/obj are properties fro the req for convenience
Example
const { err, data } = await ahttpGet("http://api.host.com/file.txt");
  const { err, obj } = await ahttpGet("http://api.host.com/user/123");
  const { err, obj } = await ahttpGet({ url: "http://api.host.com/user/123", method: "POST", postdata: { name: "myname" } });

(inner) httpGet(uri, paramsopt, callbackopt)

Description:
  • Make requests using HTTP(S) and pass it to the callback if provided

Parameters:
Name Type Attributes Description
uri string | object

can be full URL or an object with url:

params httpGetRequest <optional>

customize request with options, see module:httpGet.httpGetRequest

callback function <optional>

callback as (err, request) where request is {httpGetRequest} object combined with input params and updated fields

Example
httpGet("http://api.host.com/user/123", (err, req) => {
     if (req.status == 200) console.log(req.obj);
  });