GithubHelp home page GithubHelp logo

raineorshine / request-promise Goto Github PK

View Code? Open in Web Editor NEW

This project forked from request/request-promise

0.0 2.0 0.0 149 KB

Promise-based Wrapper for Simple HTTP Requests built on top of Bluebird and Request

JavaScript 100.00%

request-promise's Introduction

Request-Promise

A Promises/A XHR wrapper for Bluebird and Request

Bluebird and Request are pretty awesome, but I found myself using the same design pattern. This is a simple wrapper that takes in a request options object (or URI string), and returns a chainable promise. By default, http response codes other than 200 and 201 will cause the promise to be rejected. This can be over-ridden by setting options.simple to false.

Installation

npm install request-promise

Examples

var rp = require('request-promise');

rp('http://www.google.com')
    .then(console.dir)
    .catch(console.error);

//'GET's and displays google.com

var options = {
    uri : 'http://posttestserver.com/post.php',
    method : 'POST'
}; 

rp(options)
    .then(console.dir)
    .catch(console.error);

//displays response from server after post

options.transform = function (data) { return data.length ;};

rp(options)
    .then(console.dir)
    .catch(console.error);

//transform is called just before promise is fulfilled
//displays length of response from server after post

MIT Licenced

request-promise's People

Contributors

tyabonil avatar courajs avatar floatdrop avatar raineorshine avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.