1let isLoading = true;
2
3fetch(myRequest)
4 .then(function(json) { /* process your JSON further */ })
5 .catch(function(error) { console.error(error); /* this line can also throw, e.g. when console = {} */ })
6 .finally(function() { isLoading = false; });
7