Code Monkey home page Code Monkey logo

restler-q's Introduction

restler-q Build Status

(C) Andrew Newdigate (@suprememoocow), Licensed under the MIT-LICENSE

An extremely simple Q promises wrapper for Don Wrong's Restler library.

Installing

npm install restler-q

Using

The interface is similar to Restler's interface:

var rest = require('restler-q');

rest.get('https://api.github.com/orgs/Troupe/repos')
  .then(function(repos) {
    assert(Array.isArray(repos));
  })
  .nodeify(done);

If you would like to gain access to the response object, do it like this

var rest = require('restler-q').spread; // Note the .spread on the end!
rest.get('https://api.github.com/orgs/Troupe/repos')
  .spread(function(repos, response) {
    // Use Q's `spread`, not `then` 
    assert(Array.isArray(repos));
  })
  .fail(function(err) {
    // err.response contains the HTTP Response
  })
  .nodeify(done);

Running the tests

npm install
make test

TODO

  • Provide ability to call abort and retry methods.

restler-q's People

Contributors

suprememoocow avatar mydigitalself avatar trevorah avatar stewartmckee avatar

Stargazers

Scott Elcomb avatar Emma Williams avatar Tao Shi avatar Alf Eaton avatar Jake avatar  avatar

Watchers

 avatar Eric Eastwood avatar  avatar James Cloos avatar Tomas avatar  avatar José Iván Vargas avatar Marc von Holzen avatar Clement Ho avatar Ola  avatar  avatar  avatar

restler-q's Issues

putJson

missing "putJson", "patchJson" methods

Getting responses back

It looks like you are discarding the second argument of restler's .on() functions. How can I find out what the HTTP response code was? I want to basically use this library to keep looping until I get a 200 response.

Timeout

Missing support for the timeout option. No event is fired upon timeout.

A way to access `restler.data` and `restler.file`

I'm still using both requite('restler-q') and requite('restler') as I need the latter to access data and file… would it make sense to make them visible in the wrapper, so that restler wouldn't need to be a direct requisite no more? (with no need to wrap anything in those)

Using `.spread` gives error on error

Seems like err.response can be written to.

TypeError: Cannot assign to read only property 'response' of 
    at Request.<anonymous> (/home/...myproj/node_modules/restler-q/lib/restler-q.js:17:29)
    at Request.emit (events.js:110:17)
    at ...

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.