0

Error of CORS if we use mode:"no-cors" than nothing happens

Code :

    fetch(
      "http://url")
      .then(function (response) {
        if (!response.ok) {
          throw new Error("HTTP error, status = " + response.status);
        }
        return response.json();
      })
      .then(function (json) {
        console.log(json);
      })
      .catch(function (error) {
        console.log("Error: " + error.message);
      });
Darshan
  • 3
  • 2
  • Tried to use response.text() also but the same problem. – Darshan Jan 27 '22 at 11:49
  • The website you're making the request to has expressly disallowed requests from client-side JS by not including CORS headers in the response. There's nothing you can do to make the AJAX call work on the client side. You will need to make the request from the server side instead. – Rory McCrossan Jan 27 '22 at 11:54
  • "Error of CORS if we use mode:"no-cors" than nothing happens" — this is covered by the second duplicate – Quentin Jan 27 '22 at 12:09

0 Answers0