Is this expected? I am testing the error checking of my code by forcing a GET error. That is, I turned off the endpoints on purpose. Oddly I am getting two errors for each single error.
I verified my fetch() request only occurs once by logging it to the console.
However I see two errors in the console. I wanted to make sure that for some reason the browser is not fetching the data twice.
Is this expected behavior? If so where is it documented?
GET http://localhost:3000/users/user 404 (Not Found)
It occurs twice for a single fetch();
Here is the fetch()
const options = {
credentials: 'include'
};
fetch('/users/user', options)
.then((response) => {
return response.json();
})
.then((user) => {
if(user) {
dispatch({type: 'initializeUser', current: user});
}
})
.catch((err) => {
console.error('DEBUG: F1Data: /users/user endpoint failed : ', err);
})
Similarly, I see my own error being thrown twice as well:
DEBUG: F1Data: /users/user endpoint failed : SyntaxError: Unexpected token < in JSON at position 0