The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Fetch – No 'Access-Control-Allow-Origin' header is present

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #255445
    Ollie Williams

    I am testing out the new fetch API on my localhost.

    I am getting this error message in the console.

    Fetch API cannot load No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:7883’ is therefore not allowed access. The response had HTTP status code 400. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

    This is my code. I’m attempting to use the Twitter API:

    var query = '';
    var options = {
      method: 'GET',
      mode: 'cors',
    fetch(query, options)
    .then(response => {
      if (response.status >= 200 && response.status  console.log(data))
    .catch(() => console.log("whatever"))

    Hello, I wondering if you’ve succeeded to solve the issue you had. I have the same issue (that’s the way I got here). Is it possible to share this with me and help me. Thank you very much! Regards, Elena

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.