How to handle 4xx and 5xx errors in Javascript fetch()