/yahp

Yet another node.js http client library that solves all your needs.

Primary LanguageJavaScriptMIT LicenseMIT

YAHP (Yet another HTTP client package) Build Status Coverage Status

Yet another node.js http client library that solves all your needs.

Installation

npm install yahp

How to make requests?

GET request.

var client = require('yahp');
var response = client.get('https://www.google.com/');

POST request.

var client = require('yahp');
var response = client.post('http://localhost:3000/', {
    contentType: 'application/json',
    data: {
        name: 'Goutam'
    }
});

Similarly, you can use put, patch, and delete methods respectively.

How to make authenticated requests?

Just use auth property to make basic authenticated requests.

var client = require('yahp');
var response = client.get('http://localhost:3000/protected', {
    auth: 'user:password'
});

To make other requests like Token, Bearer authentication mechanisms.

var client = require('yahp');
var response = client.get('http://localhost:3000/protected', {
    headers: {
        Authorization: 'Bearer token'
    }
});