Reputation: 697
i try to get google suggestion from this url http://suggestqueries.google.com/complete/search?q=bob&client=firefox
when i run the url i get this result : ["bob",["bobby shmurda","bob marley","bobbi kristina","bobbi brown","bobbi kristina brown","bob dylan","bob evans","bobby hurley","bob\u0027s burgers","bob seger"]]
in node.js i used request , heres my code :
var request = require('request');
var url = 'http://suggestqueries.google.com/complete/search?q=bob&client=firefox';
request(url,function(error, response, result){
if(!error){
console.log(result);
}
});
until now everythings work fine
as you can see my output is an array with two values, in above code when i try to get result[1]
instead of show array its just show a "
.
i dont know why this happen.
Upvotes: 0
Views: 242
Reputation: 26476
probably because you get a String and not a JSON. try JSON.parse
result = JSON.parse(result)
Upvotes: 1