wiki/content/20201111095454-javascript_promises_finally.md

590 B

date id title
2020-11-11 189b65a7-906f-41fd-91cd-57c4cc5764d2 JavaScript Promises Finally

Introduction

Like Exceptions, since ES2018 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;
  }
);