Giter VIP home page Giter VIP logo

node-quester's Introduction

Quester

Let's go on a (re)quest.

What is Quester?

Quester is a smallish wrapper around Request that makes it easy to make batch requests and handle the response as one unit.

It also has support for depdendencies between requests. So POST data or parameters from a request can be used as data to another request. This is done using JSONPath.

Installation

Install using npm per usual.

npm install quester --save

Example Usage

The Quester API is pretty simple. This is how you make a GET request.

var quester = require('quester');
var client  = new quester('http://base.url.for.api.com/api');

client.get('/thing')
  .execute(function (err, result, requests) {
    if (err) throw err;

    // Result is an array of all the performed requests in the current batch
    // In this case a single JSON object.
    var thing = result[0];

    // Requests is an array of the performed requests. Index of result and
    // requuests match up.
    console.log('Finished fetching:', requests[0].uri);
  });

Making batch requests

Quester makes it easy to make a bunch of requests at once and process them in one callback.

Please don't mind the terrible HTTP API "design" below.

var quester = require('quester');
var client  = new quester('http://base.com');

// Queue a get request with additional querystring parameters
client.get('/thing', { sort: 'asc' });

// Queue a post request
client.post('/blog', { title: 'Post title', body: 'lorem ipsum' });

// Suppose '/blog' returns an object with the newly created posts id
// and you have an API to get comments for a blogpost.
// Setting a parameter to an object with the key "jsonpath" let's you
// Add data from a previous request.
client.get('/blog/comments', { forPost: { jsonpath: '$.id' } });

API

node-quester's People

Contributors

simme avatar

Watchers

Hugo Wetterberg avatar John O'Neill avatar James Cloos avatar Dan Carlberg avatar christian avatar Justin Medoy avatar Alex Qin avatar  avatar Billy Ohgren avatar Adam Nyberg avatar Eric Doty avatar Emil Vikström avatar Nicholas Vincent DiSanto avatar  avatar Dev0 avatar Daniel Tyner-Bryan avatar Jake Etter avatar Nichole Boseman avatar Skye Freeman avatar Nancy Thornton avatar  avatar Bloglovin CI avatar Alex Harris avatar Darren avatar Douglas Moore avatar  avatar Kevin Naughton Jr. avatar  avatar  avatar  avatar Suraj Kumar Maurya avatar  avatar  avatar Rashmi 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.