a blog for those who code

Tuesday 24 March 2015

Superfetch - Nodejs HTTP Client

In this post we are going to discuss about Superfetch which is a super powerful node.js HTTP client with support of promise.

Now you might be thinking that since we have request (Simplified HTTP request client), then whats the use of Superfetch. This superfetch will come handy if you have a number of requests. Superfetch is very easy to use.


npm install -g superfetch

How to Use

var fetch = require('superfetch');
fetch.get('http://www.google.com').then(function (body) {
/* This response body will be returned and this code will execute if the status code begins with '2' */
}).catch( function (response) {
// Otherwise the whole response body will be returned in this

As per Superfetch the API's are 

PC : https://www.npmjs.com/package/superfetch

Please Like and Share the Blog, if you find it interesting and helpful.

No comments:

Post a Comment