Package Exports
- @superhero/request
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@superhero/request) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Request
Licence: MIT
A wrapper for the http and https modules request function. I put this together to be able to simplify my api requests..
Install
npm install @superhero/request
...or just set the dependency in your package.json file:
{
"dependencies":
{
"@superhero/request": "*"
}
}Example
const api = require('@superhero/request');
api.get({url = 'example.com/foobar'}, (error, dto) => console.log(dto.status, dto.data));
api.post({url = 'https://example.com/foobar', data: {foo:'bar',baz:'qux'}}, console.log);Options
All options are optional.
{
// if true, some output for debugging is logged to the console
debug: false,
// the actual url, if no protocol is specified in the url, http is assumed
url: '',
// an object map of the data to send with the request
data: undefined,
// an object map of headers to send with the request
headers: {}
}