We are finding that occasionally our .fetch command is returning a 404. Even though the file exists and is hit regularly sometimes it's receiving a 404.
window.fetch('/category/somepage', {
credentials: 'same-origin',
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(app.addAntiForgeryToken(postData))
})
.then(function(response) {
if (response.ok) {
return response.json();
}
throw new Error('Network response was not ok');
})
.then(result => {
if (result.Status === 'OK') {
//...
}
})
At the moment it is being caught with the throw new Error
.
As we need this to resolve, what is the best way to force try this again until the page is hit? Should we show a button for retry or is there a way to loop this? I'm not sure why this would even throw a 404 as the file definitely exists all the time.