Answers for "promises in javascript greeper"

0

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  -->
Posted by: Guest on August-15-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language