I tried to post some data on a certain URL using fetch API and XHR but both of them didn't work and response with 401 status, and when I am testing the post request on postman it work normally.
const rawl = fetch("URL GOES HERE", {
  method: 'POST',
  mode: 'no-cors',
  credentials: "same-origin",
  data: {
    "name": "SOME INPUT VALUES HERE",
    "input": {}
  },
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "TOKEN GOES HERE"
  },
});
rawl.then((data) => {
  console.log(data);
})
this with fetch api and this one with xhr
var xmlhttp;
if (window.XMLHttpRequest) {
  xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    document.getElementById("demo").innerHTML =
      this.responseText;
  }
};
xmlhttp.open("POST", "URL GOES HERE", true);
xmlhttp.setRequestHeader("Content-type", "application/json");
xmlhttp.setRequestHeader("Accept", "application/json");
xmlhttp.setRequestHeader("Authorization", "TOKEN GOES HERE");
xmlhttp.send({
  "name": "INPUT VALUE GOES HERE",
  "input": {}
});
This return with error: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 401.
but on postman it normally goes with same headers and values!!!
 
     
     
    