Cors 接收编号';访问控制允许原点';请求的资源上存在标头,并且存在axios get请求
我正在使用以下请求:Cors 接收编号';访问控制允许原点';请求的资源上存在标头,并且存在axios get请求,cors,axios,Cors,Axios,我正在使用以下请求: 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 =&g
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}));
但是我仍然收到
在我的控制台上请求的资源上没有“Access Control Allow Origin”头。使用Postman时,url在获取结果时工作正常。我做错了什么?通过npm安装cors--save
,删除{headers:{'Access-Control-Allow-Origin':'*}}
并重新运行localserver来解决