Reputation: 238
I must be doing something wrong, but I am trying to ping a service until I get a 200 response. When I look in the network tab in my browser (chrome), I get a 304:
However, when I print out the following code:
const s1 = await fetch(`./${cluster}/api`)
const s2 = await fetch(`./${cluster}/dashboard`)
console.log(s1.status, s2.status)
I get:
It's hard to read sorry, but it says 200 200.
Why do I get a 200 when I check the status, but a 304 in the network tab?
Upvotes: 1
Views: 443
Reputation: 12909
As you can see from here (scroll down to "redirect):
Normally, fetch transparently follows HTTP-redirects, like 301, 302 etc.
fetch
follows HTTP redirects, so you are getting a 304, fetch will then load the page from cache, since a 304 Not Modified
means that the cached page is still valid.
Also work reading https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections#special_redirections
Upvotes: 4