Last active
July 29, 2016 11:16
-
-
Save nchanged/8f29daf6ea5de72c9fb5b6f194baf300 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let auth = (user, pwd) => { | |
return new Promise((resolve, reject) => { | |
if( user !== "foo" && pwd !== "bar"){ | |
return reject({ message : "Wrond credential"}) | |
} | |
return resolve({ | |
user : user | |
}); | |
}); | |
} | |
let promoteUser = (user) => { | |
return new Promise((resolve, reject) => { | |
user.admin = true; | |
return resolve(user); | |
}); | |
} | |
auth("foo", "bar") | |
.then(promoteUser) | |
.then((user) => { | |
console.log(user) | |
}).catch((e) => { | |
console.log(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment