【发布时间】:2017-08-28 19:26:37
【问题描述】:
我正在使用 Reactjs,我正在尝试使用 Axios 发出 POST 请求,以便使用 Nexmo 发送 SMS。我可以接收短信,但控制台上出现此错误请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,Origin 'http://localhost:3000' 不允许访问。 这是我的代码:
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);
});
我该如何解决这个问题?谢谢
【问题讨论】:
-
@Zoomzoom 我也面临同样的情况——你是怎么解决的?
标签: reactjs post access-control axios nexmo