.catch with function js code example
Example: 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.