Hi,
I don’t know much about Node, just started learning recently.
I’m trying to make an image search project by using google custom search api.
I want to use this package provided by node:
https://www.npmjs.com/package/google-images
This is the code given in the link:
const GoogleImages = require('google-images');
const client = new GoogleImages('CSE ID', 'API KEY');
client.search('Steve Angello')
.then(images => {
/*
[{
"url": "http://steveangello.com/boss.jpg",
"type": "image/jpeg",
"width": 1024,
"height": 768,
"size": 102451,
"thumbnail": {
"url": "http://steveangello.com/thumbnail.jpg",
"width": 512,
"height": 512
}
}]
*/
});
// paginate results
client.search('Steve Angello', {page: 2});
// search for certain size
client.search('Steve Angello', {size: 'large'});
But I am not being able to use it properly. I got my own API KEY and CSE ID properly. I was expecting to get some results when I write console.log(images)
but it returns an empty object []
These are the dependencies in my package.json file looks like:
"dependencies": {
"axios": "^0.16.2",
"cheerio": "^1.0.0-rc.2",
"google-images": "^2.1.0",
"got": "^7.1.0",
"request": "^2.81.0"
}
What exactly do I need to do to get search results in json format? I tried looking around a lot to know what am I missing but didn’t get any info.