function requestAsync(params) {
return new Promise((resolve, reject) => {
request(params, (err, response, body) => {
if(err) { return reject(err); }
resolve({response, body});
});
});
}
async function getURL(_url) {
var data, url = _url;
do {
const {body} = await requestAsync({url});
data = JSON.parse(body);
url = _url + '&pageToken=' + data.nextPageToken;
} while(data.nextPageToken !== undefined);
return data;
}