how to handle fetch errors
function CheckError(response) {
if (response.status >= 200 && response.status <= 299) {
return response.json();
} else {
throw Error(response.statusText);
}
}
// Now call the function inside fetch promise resolver
fetch(url)
.then(CheckError)
.then((jsonResponse) => {
}).catch((error) => {
});