ES7 async/await ready http client


A light, fluent node.js HTTP client for ES6. Heavily inspired by superagent as well as fetch. Designed with ES7 async/await in mind.

The API is quite minimal for now. Features will be added while people request or use them.

var req = require('requisition');
// GET a JSON body 
async function () {
  var res = await req('/users.json');
  var body = await res.json();
// POST an image file 
async function () {
  var res = await'/images.json').sendFile('image.png');
  var body = await res.json();
var request = require('requisition');

GET a url, return the response object.

VERB a url, specifically when it's not GET.

Send the request and wait for the response.

request('/').then(function (response) {

Set an object of headers.

Set a single header.

The status code of the response.

The header object of the response.

Infer the Content-Type of the response, similar to Koa or Express' method. See type-is.

Get the value for a header.

Return a single Buffer for the entire response.

Return a single String for the entire response.

Automatically parse the JSON of the response.

request('/users.json').then(function (response) {
  assert(response.status === 200, 'Bad response!');
  assert('json'), 'Bad type!');
  return response.json()
}).then(function (body) {

Save the response to a file.

request('/file.txt').then(function (response) {
  return response.saveTo('/tmp/file.txt');
}).then(function () {
  console.log('file saved!');

Dumps the response. Execute this if you haven't handled the body.

Destroy the response.