我正在使用Reactjs,我正尝试使用Axios发送POST请求以发送Nexmo的短信。我可以收到短信,但在控制台上出现此错误请求的资源上没有“Access-Control-Allow-Origin”标头。因此,'http://localhost:3000'因此不允许访问。 这里是我的代码:Reactjs - Axios - Nexmo POST请求无法正常工作(No'Access-Control-Allow-Origin')
axios({
method : 'post',
url : 'https://rest.nexmo.com/sms/json',
params:{
api_key:'xxxxxxxxx',
api_secret:'xxxxxxxxx',
to:phoneNumber,
from:'NEXMO',
text:"New message"
},
headers:{
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
我该如何解决这个问题? Thx
[“No'Access-Control-Allow-Origin'标头存在于请求的资源中”](http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-头部是在请求的资源) –
@Zoomzoom我面临同样的情况 - 你是如何解决这个问题的? – whodeee