Error handling for JS fetch requests

The following example handles server and connectivity errors for javascript fetch requests. handleErrors can be updated for handling different types of errors in different ways. This function is called whenever we get a response from the server (successful or failed). When we have a different type of error, like a DNS one, the catch block…