Skip to content

Instantly share code, notes, and snippets.

@dodozhang21
Created June 16, 2017 02:39
Show Gist options
  • Save dodozhang21/8c0c432c98f34b8daf04136efadacbf4 to your computer and use it in GitHub Desktop.
Save dodozhang21/8c0c432c98f34b8daf04136efadacbf4 to your computer and use it in GitHub Desktop.
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