fetch receiving http status 0

Asked

Viewed 51 times

0

I created a small project on webstorm with an html that fetch from my localhost:3340

fetch('http://httpbin.org/get')
    .then(
        function(response){
            console.log("response ok");
            return response.json();
        }
    )
    .then(function (json){
            console.log("json ok");
        }
    ).catch(function(error) {
        console.log('ERROR: ' + error.message);
    });

I can’t figure out the cause of the mistake "Networkerror when attempting to fetch Resource." appearing on the Firefox console. This message doesn’t help me much because it seems to me genetic.

Firefox is updated in the latest version

Someone could show me a way. As I cannot identify the cause of the problem I cannot study a solution.

I managed the file . har to see if I discovered something and I think this is the answer that I have:

"response":{

    **"status":0**,
    "statusText":"",
    "httpVersion":"",
    "headers":[
    ],
    "cookies":[
    ],
    "content":{
        "size":0,
        "encoding":"base64",
        "text":""
    },
    "redirectURL":"",
    "bodySize":-1

}

in advance thank you for the support !

  • It’s probably a CORS error, look at the browser console that should display an error.

  • @Pedrosanção, I wish it was because then I would have at least one way to go, but I can’t determine why the only message that appears on the firefox console is : ERROR: Networkerror when attempting to fetch Resource.

1 answer

0

304 isn’t exactly a mistake. It usually occurs when the browser realizes that the requested resource exists in cache, so it "does not" the request and returns the data that already existed in cache.

  • Can I do a test by clearing the firefox cache ? Can you tell me how I do that? If it doesn’t work I’ll include it in the main post.

  • @Phabioricard Following link from the Mozilla community, step by step to clear the cache (https://support.mozilla.org/pt-BR/kb/howto clear cache-firefox)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.