Promise apply under getAsyncData function and it return resolved or rejected.
If it resolved then then() block is triggered else in the case of rejected catch() block
// Neel.B
const getAsyncData = () => {
return new Promise((resolved,reject)=>{
setTimeout(() => {
resolved('This call is resolved !!')
}, 2000) // function run after 2 seconds
})
}
getAsyncData().then((result)=>{
console.log(result)
}).catch((err)=>{
console.log(err)
})
© www.thecoderjob.com. All Rights Reserved. Designed by HTML Codex