promises in javascript greeper
// an illustration of the javascript promises
function userLogin(name , email){
return new Promise((resolve , reject) => {
setTimeout(()=> {
resolve(
{
userName: name ,
userEmail : email,
}
)
reject( new Error("Failed to Get User's Credentials"))
} , 3000);
})
}
userLogin('kevin' , '[email protected]').then( user => {
console.log(user);
});
<!-- Happy coding -->