promise prototype finally

Solutions on MaxInterview for promise prototype finally by the best coders in the world

showing results for - "promise prototype finally"
Diane
06 Oct 2018
1let isLoading = true;
2
3fetch(myRequest).then(function(response) {
4    var contentType = response.headers.get("content-type");
5    if(contentType && contentType.includes("application/json")) {
6      return response.json();
7    }
8    throw new TypeError("Oops, no hemos obtenido un JSON!");
9  })
10  .then(function(json) { /* procesar el JSON */ })
11  .catch(function(error) { console.log(error); /* esta línea podría arrojar error, e.g. cuando console = {} */ })
12  .finally(function() { isLoading = false; });
13
14