# Fetch doesn't return 404 status

**URL:** <https://forums.fusetools.com/t/fetch-doesnt-return-404-status/5491>\
**Category:** Bug Reports\
**Created:** [October 16, 2016, 1:49am UTC](https://forums.fusetools.com/t/fetch-doesnt-return-404-status/5491 "2016-10-16T01:49:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/michael/32/121_2.png) [@Michael](https://forums.fusetools.com/u/Michael)\
**Post date:** [October 16, 2016, 1:49am UTC](https://forums.fusetools.com/t/fetch-doesnt-return-404-status/5491/1 "2016-10-16T01:49:36Z")

</div>

Hi Guys,

I have the following code:

```
   fetch('http://asfklajsdflkajsdfkj.com/test', {
	    method: 'POST',
	    headers: { "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"},
	    body: "InpNumber=" + InpNumber.value
	}).then(function(response) {
		console.log(response);
	    var status = response.status; // Get the HTTP status code
	    var response_ok = response.ok; // Is response.status in the 200-range?
	    return response.json(); // This returns a promise
	}).then(function(response) {
		if(response.result == 'success'){
			ActivationID = response.data.validation;
			setState(3, null);
		} else {
			setState(2, response.error);
		}
	}).catch(function(err) {
		console.log(err);
		setState(2, "An error has occurred");
	});

```

I have put in a random URL in the fetch parameters as shown to simulate what it would be like if there was a server down or not found. For some reason fetch doesn’t return any response when there is a 404 error or throw an error that is caught. Any ideas on how to catch 404 error?

---

<div class="post-metadata">

**Author:** ![Donald](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@Donald](https://forums.fusetools.com/u/Donald)\
**Post date:** [October 16, 2016, 11:35am UTC](https://forums.fusetools.com/t/fetch-doesnt-return-404-status/5491/2 "2016-10-16T11:35:40Z")

</div>

i think, that it will be more issues with “fetch” … [https://www.fusetools.com/community/forums/howto\_discussions/typeerror\_network\_request\_failed\_on\_https](https://www.fusetools.com/community/forums/howto_discussions/typeerror_network_request_failed_on_https)

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [October 18, 2016, 9:23am UTC](https://forums.fusetools.com/t/fetch-doesnt-return-404-status/5491/3 "2016-10-18T09:23:43Z")

</div>

A random generated URL is a very bad test-case since you never know what you will hit. In the case above you try to target a domain that does not exists. So the server can not reply with any errors at all. So you don’t get any answer. 404 is a response you get when a client has entered an URL that the server does not understand, hence you need to have communication with the server first.

---

<div class="post-metadata">

**Author:** ![Michael](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/michael/32/121_2.png) [@Michael](https://forums.fusetools.com/u/Michael)\
**Post date:** [October 18, 2016, 10:13am UTC](https://forums.fusetools.com/t/fetch-doesnt-return-404-status/5491/4 "2016-10-18T10:13:31Z")

</div>

Good point Anders - but how do I detect if the Fetch cannot find any server??

For example, my servers crash or my domain expires, how does the app detect that fetch is failing?

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [October 18, 2016, 11:47am UTC](https://forums.fusetools.com/t/fetch-doesnt-return-404-status/5491/5 "2016-10-18T11:47:38Z")

</div>

After testing I can see that we are not throwing any exception. That could be because the timeout is very long, but I’m not sure. I’ve raised an internal issue to investigate.

---

<div class="post-metadata">

**Author:** ![Michael](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/michael/32/121_2.png) [@Michael](https://forums.fusetools.com/u/Michael)\
**Post date:** [October 18, 2016, 12:23pm UTC](https://forums.fusetools.com/t/fetch-doesnt-return-404-status/5491/6 "2016-10-18T12:23:17Z")

</div>

Thank you.

While investigating could you please provide an update on when FormData will be made available for use - so photos/videos can be easily uploaded.

And if there is any plans to support a fetch cancel function/method.

Thanks  
Michael

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [October 19, 2016, 12:02pm UTC](https://forums.fusetools.com/t/fetch-doesnt-return-404-status/5491/7 "2016-10-19T12:02:14Z")

</div>

I can’t say when FormData will be available because we have a lot of other high pri tickets on HTTP that needs to be done first. But we do have it on the list.

Fetch cancel: Yes, that is indeed something we want. But as you can see from the [whatwg issue 27](https://github.com/whatwg/fetch/issues/27) this is a very complex problem. We are following the effort [here](https://github.com/tc39/proposal-cancelable-promises) that we hope will end up as a general solution we can depend on.

If you need something like timeout or cancel, you could use `setTimeout` or use `XMLHttpRequest.abort()`.
