Global

Methods

phin(options, callbackopt, httpModuleopt)

Sends an HTTP request
Parameters:
Name Type Attributes Default Description
options phinOptions | string phin options object (or string for auto-detection)
callback phinResponseCallback <optional>
null Callback to which data is sent upon request completion
httpModule Object <optional>
require('http') HTTP module injection (for testing)
Source:

Type Definitions

phinOptions

phin options object
Type:
  • Object
Properties:
Name Type Attributes Default Description
url string URL to request (autodetect infers from this URL)
method string <optional>
GET Request method ('GET', 'POST', etc.)
data string | Object <optional>
Data to send as request body (if Object, data is JSON.stringified unless content-type header is present and set to 'application/x-www-url-form-encoded' in which case the data will be encoded as a query string.)
headers Object <optional>
{} Request headers
hostname string <optional>
autodetect URL hostname
port Number <optional>
autodetect URL port
path string <optional>
autodetect URL path
compression boolean <optional>
false Enable compression for request
auth string <optional>
autodetect Request authentiction in "user:password" format
Source:

phinResponseCallback(errornullable, phinResponsenullable)

Response data callback
Parameters:
Name Type Attributes Description
error Error | string <nullable>
Error if any occurred in request, otherwise null.
phinResponse http.serverResponse <nullable>
phin response object. Like http.ServerResponse but has a body property containing response body
Source: