how can i use catch with async function ?
async function withAsync(num) {
if (num === 0){
return 'zero';
} else {
return 'not zero';
}
}
// Leave this commented out until step 3:
withAsync(10)
.then((resolveValue) => {
console.log(` withAsync(100) returned a promise which resolved to: ${resolveValue}.`);
})
.catch((rejectValue) => {
console.log(`rejected value is ${rejectValue}`);
})
this print log of then only.