I want to search google for three images to display on my site.
I thought this was the minimum info the api needed to get the information but maybe I'm missing something. Google isn't being very helpful on this.
const GOOGLE_API_URL = 'https://www.googleapis.com/customsearch/v1';
async function google_image_search(searchTerm){
const response = await axios({
method:'GET',
url:GOOGLE_API_URL,
params:{
q:searchTerm,
num:3,
searchType:'image',
key:API_KEY,
}
});
return response;
}
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [
{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
I figured it out. I had to set it to images in the control panel of the custom search engine in my google developer settings.