Created
June 16, 2017 02:39
-
-
Save dodozhang21/8c0c432c98f34b8daf04136efadacbf4 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
var request = require('request'); | |
getAdminUserStatus('user2', 'pass2') | |
.then(bindTestAcount) | |
.then(checkUser); | |
function getAdminUserStatus(name, pass) { | |
return new Promise(function (resolve, reject) { | |
request("http://google.com", function (error, body) { | |
if (!error) { | |
resolve({'username': name, 'password': pass}); | |
} else { | |
reject(false); | |
} | |
}); | |
}); | |
} | |
function bindTestAcount(json) { | |
return new Promise(function (resolve, reject) { | |
resolve({'username': json.username + 'helloKitty', 'password': json.password + 'superMan'}); | |
}); | |
} | |
function checkUser(json) { | |
console.log('user', json.username); | |
console.log('pass', json.password); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment