C#C
C#4y ago
32 replies
İrşat

Fetch api response status code always 200

.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*";
            }
        })

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.
Was this page helpful?