1

Reactjs を使用しており、Nexmo で SMS を送信するために Axios で POST リクエストを実行しようとしています。SMS は受信できますが、コンソールにこのエラーが表示されます要求されたリソースに 'Access-Control-Allow-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);
});

この問題を解決するにはどうすればよいですか? どうも

4

1 に答える 1