Javascript Promise reject()

Introduction

To create rejected promises, use the Promise.reject() method.

let promise = Promise.reject(42);

promise.catch(function(value) {
    console.log(value);         // 42
});/*  ww w. j a  v a2s.  com*/

Any additional rejection handlers added to this promise would be called, but not fulfillment handlers.




PreviousNext

Related