Answers for "javascript finally catch promise"

-1

promise finally in js

let isLoading = true;

fetch(myRequest)
  .then(function(json) { /* process your JSON further */ })
  .catch(function(error) { console.error(error); /* this line can also throw, e.g. when console = {} */ })
  .finally(function() { isLoading = false; });
Posted by: Guest on July-28-2021
2

javascript try catch finally return

(function() {
  try {
    try {
      throw new Error('oops');
    } catch (ex) {
      console.error('inner', ex.message);
      throw ex;
    } finally {
      console.log('finally');
      return;
    }
  } catch (ex) {
    console.error('outer', ex.message);
  }
})();

// Output:
// "inner" "oops"
// "finally"
Posted by: Guest on December-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language