promise-http
0.1.5 • Public • Published
Promise HTTP
A simple wrapper for q-io/http
that handles erroneous responses and rejects the promise accordingly.
Installation
npm install promise-http --save
Usage
The request can be anything that compatible with q-io/http#request
GET
Http = require('Http').client
request = Http.get('http://some.url').then(function(response){
});
request.then(function(response){
}, function(reason){
});
POST
Http = require('Http').client
Http.post('http://some.url').then(function(response){
});
request = Http.post({
url: 'http://some.url',
body: ['text'],
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
request.then(function(response){
});
request.fail(function(reason){
})
Package Sidebar
Install
Weekly Downloads