我正在尝试通过以下方式向Google地理编码API发出获取请求:
const request= require('request');
request('https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=API_KEY_XXXXXX',
{ json: true }, (error, response, body) => {
if (error) { return console.log(error);}
console.log(body);
});
它返回:
{ error_message:
'You have exceeded your daily request quota for this API. If you did not set a custom daily request quota, verify your project has an active billing account: http://g.co/dev/maps-no-account',
results: [],
status: 'OVER_QUERY_LIMIT' }
当我直接在浏览器上键入链接时,有时它可以工作并为我提供正确的数据,但是当通过Node请求时,它总是返回该数据。在google平台上,我已请求免费的API密钥,并且我确定我没有超过配额。
您有什么建议吗?预先感谢!