我想查詢的地方自動完成API由谷歌,使用下面的代碼片斷谷歌地方網頁API不SuperAgent的
request.get(`https://maps.googleapis.com/maps/api/place/autocomplete/`).query(params)
有了正確的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合作。
相關https://stackoverflow.com/questions/44336773/google-maps-api-no-access-control-allow-origin-header-is-present-on-the-reque/44339169#44339169和https: //stackoverflow.com/questions/43443836/angular-cors-jsonp-and-google-maps-http-api-calls/43444274#43444274 – sideshowbarker