r/javascript • • Jul 10 '16

The JavaScript language reboot is done

https://medium.com/@velmu/the-javascript-language-reboot-is-done-7bcec4be2cb6#.dy2fyy9j1
41 Upvotes

98 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jul 10 '16

[deleted]

1

u/[deleted] Jul 10 '16

Cool, I wasn't aware you could chain thens like that. Although this version doesn't check if the status was ok =P

0

u/[deleted] Jul 10 '16

[deleted]

10

u/pertheusual Jul 10 '16

That's not true, the promise returned by fetch() only rejects if there is a proper network error or the connection itself doesn't get established. No matter what the status code is, it'll still resolve. There's nothing wrong with returning JSON in the body of a 500 for instance.

If there was a 404 with no JSON, your example would just throw an exception because json would be undefined so undefined.filter would be non-existant.