cockrel-request
v1.2.4
Published
Cockrel plugin for making HTTP requests
Downloads
6
Readme
cockrel-request
Cockrel plugin for making HTTP requests
Install
Require cockrel and pass it to cockrel-request to load the plugin:
const co = require('cockrel');
require('cockrel-request')(co); // Good to go!
Usage
cockrel-request is a wrapper around request and follows the same basic conventions. It exposes several new step methods:
cockrel-request sets two default options differently to standard request, we set json : true by default and add a User-Agent header 'cockrel-request', both of these can be over-ridden by passing them as options.
request
Use the request API to GET some data from github about my user:
const co = require('cockrel');
require('cockrel-request')(co);
const url = 'https://api.github.com/users/g5095';
co.request(args).do(console.log).begin();
If no options are passed at all, the value of the previous step will be used.