google-batch
Sends Batch Requests to Google REST API
(C) Pradeep Mishra pradeep23oct@gmail.com
google-batch is very easy to use, it seamlessly integrate with googleapis (official node.js sdk) module. so no need to provide all background information like url, query, authorizations.
Warning
- It is in development mode , so some of apis may not work. (dont use on production, this module was for poc purpose only)
- Tested on some gmail apis only.
- Right now only application/json response/request type is supported, so no upload, download kinda things.
Features
- Simple to use
- Support googleapis method directly to make batch call
- Many helper functions to handle batch call smoothly
Example usage
var googleBatch = ;var batch = ; // important, always require googleapis using google-batch require() method.var google = googleBatch; // how to use google OAuth instance to provide access token to google-batchvar oauthClient = ;oauthClient;batch; // OR simply pass access_token directlybatch; var gmail = google; /* Do not use oauth object in google service constructer like thisit may bypass patch in a new version of googleapis module var gmail = google.gmail({ version : 'v1', oauth : oauthClient}); */ // now lets make some batch callsvar params1 = googleBatch : true maxResults : 5 userId : "me"; var params2 = googleBatch : true maxResults : 10 userId : "me"; /* notice googleBatch property, this property is required by google-batch to identify batch call and prevent it to make the request. */ // use add() method to add calls in batch// yes we can use gogoleapis method directly :) batch;batch; batch; /* In case you are getting a hard time decoding raw (base64) data of gmail body you can use this api. */ googleBatch;
npm install google-batch --save