I'm using Reactjs and I'm trying to do a POST request with Axios to send a SMS with Nexmo. I can receive the SMS but I have this error on the console No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. Here's my code :
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);
});
How can I fix this issue ? Thx