Fetch api response status code always 200
I am returning things like
return new JsonResult(StatusCode(404));in the back end and I saw it return this. Like I wanted. But I guess I don't know how to work with this result in the javascript.
return new JsonResult(StatusCode(404));.then(function (response) {
if (response.ok) {
success.innerHTML = "SUCCESS";
setTimeout(function() {
location.reload();
}, 1000);
}
else if(response.status === 404){
message.innerHTML = "*User not found*";
}
else{
message.innerHTML = "*Server error*";
}
})