Created
April 20, 2017 06:12
-
-
Save ryubro/a94144104553ec77f0068ac867641e69 to your computer and use it in GitHub Desktop.
This file contains 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
function register(username, password, orgSecret) { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
console.log('Registered with a credential:', username, password); | |
resolve({ username, password }); | |
}, 1000); | |
}); | |
} | |
function login({ username, password }) { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
console.log('Logged in with a credential:', username, password); | |
resolve('aSessionID'); | |
}, 1000); | |
}); | |
} | |
function getUserInfo(sessionID) { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
console.log('Got user info with a session ID:', sessionID); | |
resolve('some user info'); | |
}, 1000); | |
}); | |
} | |
function showUserInfo(userInfo) { | |
console.log('The user info is:', userInfo); | |
} | |
register('byoungyong@sense-os.nl', 'aPassword', 'anOrganisationCode') | |
.then((credential) => login(credential)) | |
.then((sessionID) => getUserInfo(sessionID)) | |
.then((userInfo) => showUserInfo(userInfo)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment