我正在使用以下请求:
axios.get('https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=43.2502078,13.513169&radius=1500&type=restaurant&keyword=cruise&key=MYKEY',{headers: {'Access-Control-Allow-Origin': '*'}})
.then(response => this.setState({restaurantsFetchedFromGoogle:response.data}));
但我仍然在我的控制台上收到No 'Access-Control-Allow-Origin' header is present on the requested resource
。网址正常工作,因为它在使用Postman时获取结果。我做错了什么?
答案 0 :(得分:0)
由npm install cors --save
解决,删除{headers: {'Access-Control-Allow-Origin': '*'}}
并重新运行localserver