Created
February 15, 2016 02:24
-
-
Save 34r7h/1c75210a76de6dd44e5c to your computer and use it in GitHub Desktop.
stamplay debugging for 500 error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(context, cb) { | |
var google = require('googleapis'); | |
var request = require('request'); | |
var baseUrl = 'https://www.googleapis.com/customsearch/v1'; | |
console.log(baseUrl); | |
var query = context.data.query; | |
var auth = '?key='+context.data.key+'&cx='+context.data.cx; | |
var authQuery = auth+query; | |
request(baseUrl+authQuery,function(error, response, result){ | |
if(!error){ | |
console.log(result); | |
var parsedResult = JSON.parse(result); | |
var links = []; | |
if (parsedResult.items.length > 0 ){ | |
for(var a = 0; a < parsedResult.items.length;a++){ | |
links.push(parsedResult.items[a].link); | |
} | |
} | |
cb(null, links); | |
} | |
}); | |
} ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment