UI Deploy

Curated, Short, Web UI Dev we Love.

Handling Failed HTTP Responses With fetch()

If you’re like me, you might assume this code logs “error” when run—but it actually logs “ok”.

This expectation probably comes from years of jQuery development, as jQuery’s ajax() method invokes its fail handler when the response contains a failed HTTP status code. For example, the code below logs “error” when run

view source

Advertisement