Skip to content

Instantly share code, notes, and snippets.

@rohfosho
Last active August 29, 2015 14:15
Show Gist options
  • Save rohfosho/cda8151f689697679f35 to your computer and use it in GitHub Desktop.
Save rohfosho/cda8151f689697679f35 to your computer and use it in GitHub Desktop.
var urlShortener = require('googleapis').urlshortener({version: 'v1', auth: API_KEY});
var req = Q.nbind(urlShortener.url.insert.bind(urlShortener.url));
var promises = urls.map(function(url) {
var params = {longUrl: url };
return req(params).then(function(shortenedUrl) {
console.log(shortenedUrl);
});
});
Q.all(promises).then(function() {
//DO STUFF HERE
}).catch(function(err){
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment