问题描述
我认为这是 api 获取信息所需的最少信息,但也许我遗漏了一些东西。 Google 在这方面的帮助不大。
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"
}
}
解决方法
我想通了。我必须在我的 google 开发者设置中的自定义搜索引擎的控制面板中将其设置为图像。