Browse files

Merge pull request #6 from mallocator/master

Get can now handle page tokens
  • Loading branch information...
2 parents 623ae64 + cead033 commit c8afd87d037f3cc96d2bbd5fa86a8b555638300b @machadogj committed Feb 22, 2016
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/get.js
View
17 lib/get.js
@@ -4,20 +4,27 @@ var get = function ( options ) {
var getToken = require('./getToken')(options.iss, options.key);
- return function ( url, cb ) {
+ return function ( url, nextPageToken, cb ) {
+ if (typeof nextPageToken === 'function') {
+ cb = nextPageToken;
+ delete nextPageToken;
+ }
getToken(function ( err, token ) {
-
if (err) { return cb(err); }
console.log('requesting to: ' + url);
- request.get({
+ var getParams = {
url: 'https://www.googleapis.com/bigquery/v2' + url,
qs: {
access_token: token
}
- }, function ( err, res, body ) {
-
+ }
+ if (nextPageToken) {
+ getParams.qs.pageToken = nextPageToken;
+ }
+
+ request.get(getParams , function ( err, res, body ) {
if ( err || res.statusCode !== 200 ) {
//console.log(err || res);
cb('there was a problem executing your query');

0 comments on commit c8afd87

Please sign in to comment.