Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
136 views
in Technique[技术] by (71.8m points)

javascript - 使用Google Places API时出错。 我该怎么办?(Error while using Google Places API. What should I do?)

I'm working with Google Places API .

(我正在使用Google Places API 。)

I have signed up and got an API key.

(我已经注册并获得了API密钥。)
The problem is while using fetch() function in JavaScript, it gives an error(Not a real error):

(问题是在JavaScript中使用fetch()函数时,出现错误(不是真正的错误):)

{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 "

({error_message:“您已经超出了此API的每日请求配额。如果您未设置自定义的每日请求配额,请验证您的项目是否具有有效的结算帐户: http//g.co/dev/maps-no-account ”)
predictions: []

(预测:[])
status: "OVER_QUERY_LIMIT"

(状态:“ OVER_QUERY_LIMIT”)
__proto_: Object }

(__proto_:对象})

But according to my console , there are no requests used since now.

(但是根据我的控制台 ,自此以来没有使用过任何请求。)
My code:

(我的代码:)

const BASE_URL =
    'https://cors-anywhere.herokuapp.com/https://maps.googleapis.com/maps/api/place';
const SEARCH = document.querySelector('#input');
const API_KEY = <MYAPIKEY>;
fetch(BASE_URL + "/autocomplete/json?key=" + API_KEY + "&input=London")
    .then(data => data.json())
    .then(data => console.log(data));

Before using the proxy of CORS Anywhere , it was giving error like "No Access-Control-Allow-Origin was present in the headers...."

(在使用CORS Anywhere代理之前,它会给出类似“标题中没有Access-Control-Allow-Origin ...”的错误。)
I googled the error, it said to use the proxy mentioned above.

(我搜索了该错误,它说使用上述代理。)

But I'm receiving the above said error.

(但我收到上述错误。)

What should I do?

(我该怎么办?)

PS 1: I used <MYAPIKEY> to protect my key.

(PS 1:我使用<MYAPIKEY>保护我的密钥。)

In the actual code, I've used the actual key.

(在实际的代码中,我使用了实际的密钥。)

P. S 2: In the browser, the link works fine (without cors-anywhere URL)

(P. S 2:在浏览器中,链接可以正常工作(没有cors-wherewhere URL))

  ask by Sagarika Das translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...