JavaScript Promises Finally
Introduction
Like [JavaScript Exceptions Finally](JavaScript Exceptions Finally), since ES2018 JavaScript [JavaScript Promises](JavaScript Promises) also support .finally().
Syntax
promise
.then((result) => {})
.catch((error) => {})
.finally(() => {});
Shorthand
promise.finally(() => {});
is equal to
promise.then(
(result) => {
return result;
},
(error) => {
throw error;
}
);