Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cors 接收编号';访问控制允许原点';请求的资源上存在标头,并且存在axios get请求_Cors_Axios - Fatal编程技术网

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来解决