Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

catch javascript

//Catch is the method used when your promise has been rejected.
//It is executed immediately after a promise's reject method is called.
//Here’s the syntax:


myPromise.catch(error => {
  // do something with the error.
});

//error is the argument passed in to the reject method.
Comment

JavaScript catch() method

// returns a promise
let countValue = new Promise(function (resolve, reject) {
   reject('Promise rejected'); 
});

// executes when promise is resolved successfully
countValue.then(
    function successValue(result) {
        console.log(result);
    },
 )

// executes if there is an error
.catch(
    function errorValue(result) {
        console.log(result);
    }
);
Comment

PREVIOUS NEXT
Code Example
Javascript :: closure 
Javascript :: how to strip html tags in javascript 
Javascript :: javascript select2 sortable 
Javascript :: clock picker jquery 
Javascript :: how to live reload a node js app 
Javascript :: how to add object to array javascript 
Javascript :: how to replace array element in javascript without mutation 
Javascript :: vue js filter 
Javascript :: addition of time in javascript 
Javascript :: javascript conditional ? : 
Javascript :: how to get 6 months after date object 
Javascript :: jquery elements which id doesnt contain string 
Javascript :: react pdf 
Javascript :: in compare method why we taking a and b for sorting in javascript 
Javascript :: create multiple buttons in javascript 
Javascript :: live server in javascript 
Javascript :: ReactComponent as Icon 
Javascript :: could not decode base64 cloudinary 
Javascript :: js ?. 
Javascript :: grouped bar charts in chart js 
Javascript :: delete in array 
Javascript :: react 18 double render 
Javascript :: sidenavbar js 
Javascript :: how to check for null in javascript 
Javascript :: each function 
Javascript :: jquery.slim.min.js 
Javascript :: async await nodejs 
Javascript :: javascript extract from object and array 
Javascript :: has class in jquery 
Javascript :: asynch action redux 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =