easyhttp

A simplified wrapper around the core node.js http client.

npm install easyhttp
2 downloads in the last day
2 downloads in the last week
12 downloads in the last month

EasyHttp

A simplified wrapper around the core node.js http client.

Basics

There are simple functions for 'get', 'post', 'put', and 'delete'.

With the exception of 'get', they all take a second argument in the form of a hash of params.

All require a callback function which will receive the body and the ClientResponse object.

GET

var client = require('easyhttp');
client.get('http://server.com/foo/bar',function(body,res){
    // do something
});

POST

var client = require('easyhttp');
client.post('http://server.com/users/create',
    {'fname':'Luke','lname':'Skywalker'},
    function(body,res){
        // do your thing
    }
);

Low Level

All the simple functions end up calling the 'doRequest' method, which looks like this:

var client = require('easyhttp');
client.doRequest(
    'http://server.com/service',
    {
        'method':'POST',
        'headers':{'Authorization':'token OAUTH-TOKEN'},
        'params':{'status':'You\'ll never guess what she said next ...''}
    },
    function(body,res){
        // shake your bootay
    }
);

Why?

I find the node.js http client usage to be fast but verbose, so I decided to try to simplify it.

npm loves you