Skip to content

wtfil/multiget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multiget

multiget — express middleware that allow aggregate few api request into one response

Installation

npm install multiget

API

###multiget(apiHost) — creates middleware

Example

var express = require('express'),
    multiget = require('multiget'),
    app = express();

app.use(multiget('http://localhost:4000'));
app.listen(3000);

Response format

Calling GET http://localhost:3000/api/multi?key1=api1&key2=api2 for example above will made following requests:

GET http://localhost:4000/api1
GET http://localhost:4000/api2

and will combine responces into one:

{
    key1: {
        result: /*api responce*/,
        error: /*error message*/
    },
    key2: {
        result: /*api responce*/,
        error: /*error message*/
    }
}

if API will set content-type to application/json the middleware will trying to parse response

fields error and result are mutually exclusive

Tests

npm test

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published