【发布时间】:2018-02-11 22:28:23
【问题描述】:
我正在尝试通过谷歌查询地点自动完成 api,使用以下 sn-p
request.get(`https://maps.googleapis.com/maps/api/place/autocomplete/`).query(params)
使用正确的参数,代码将失败,给我一个 CORS 异常
Failed to load https://maps.googleapis.com/maps/api/place/autocomplete/json?input=amsterdam&key={super secret key}: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:7000' is therefore not allowed access.
如果我切换到我的网络选项卡,我可以看到请求本身运行良好,它甚至返回了我想要的日期。
我正在使用 superagent-es6-promise。
【问题讨论】:
标签: reactjs google-maps cors google-places-api superagent