我想在我的项目中使用 HERE 地图自动完成功能。但是当 ai 发送像文档中那样的请求时
this.axios.get('http://autocomplete.geocoder.api.here.com/6.2/suggest.json
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&query=Pariser+1+Berl
&beginHighlight=<b>
&endHighlight=</b>'
)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
Run Code Online (Sandbox Code Playgroud)
我收到一个错误
OPTIONS http://autocomplete.geocoder.api.here.com/6.2/suggest.json?{...} 405
Access to XMLHttpRequest at 'http://autocomplete.geocoder.api.here.com/6.2/suggest.json?{...}' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Run Code Online (Sandbox Code Playgroud)
在网络面板的 Chrome 开发者控制台中我检查了这个
Provisional headers are shown
Access-Control-Request-Headers: x-auth-token, content-type
Access-Control-Request-Method: GET
Run Code Online (Sandbox Code Playgroud)
我将请求标头中的内容类型设置为 application/json 并更改了临时标头
to Access-Control-Request-Headers: x-auth-token
Access-Control-Request-Method: GET
Run Code Online (Sandbox Code Playgroud)
所以如果我理解正确,我应该设置 x-auth-token 标头。但是我可以在哪里拿到这个令牌呢?或者这个问题可能有其他原因?
文档中没有任何关于此类问题的信息。
here-api ×1