@idagio/shortwreck
v1.0.0
Published
A nice short wrapper for Wreck
Downloads
5
Readme
@idagio/shortwreck
A nice short wrapper for Wreck.
Usage
const ShortWreck = require('@idagio/shortwreck');
const ApiClient = ShortWreck({
json: true
});
ApiClient.request("GET", "https://httpbin.org/get", (err, res, payload) => {
if (err) {
console.log(err);
return;
}
console.log(res);
console.log(payload);
});
API
new ShortWreck(options)
Takes the exact same options as wreck's defaults(options)
.
ShortWreck.prototype.request(method, uri /*, [options], callback */)
method
- A string specifying the HTTP request method, defaulting to 'GET'.uri
- The URI of the requested resource.options
- Optional config object containing settings for bothrequest
andread
operations. This will override the options initially passed tonew ShortWreck(options)
.callback
- The callback function using the signaturefunction (err, response, payload)
where:err
- Any error that may have occurred during handling of the request.response
- The HTTP Incoming Message object, which is also a readable stream.payload
- The payload in the form of a Buffer or (optionally) parsed JavaScript object (JSON).
Returns an instance of the node.js ClientRequest object.