Never-ending Pumpkin Mulch

    promise-http

    0.1.5 • Public • Published

    Travis-CI Status

    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){
       // you got the data
    });
     
    request.then(function(response){
        // done
    }, function(reason){
        // something went wrong
    });

    POST

    Http = require('Http').client
     
    Http.post('http://some.url').then(function(response){
        // you know what to do...
    });
     
    request = Http.post({
        url: 'http://some.url',
        body: ['text'],
        headers: {'Content-Type': 'application/x-www-form-urlencoded'}
    });
     
    request.then(function(response){
        // all good.
    });
     
    request.fail(function(reason){
        // nope.
    })

    Install

    npm i promise-http

    DownloadsWeekly Downloads

    1

    Version

    0.1.5

    License

    MIT

    Last publish

    Collaborators

    • vinelab-frontend