console.log("Before");
getUser(1)
.then((user) => getRepositories(user.gitHubUsername))
.then((repos) => {getCommits(repos[0]);})
.then((commits) => {console.log("commits: ", commits);})
.catch((err) => console.log("Error: ", err.message));
console.log("After");
function getUser(id) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log("Reading a user from a database...");
resolve({ id: id, gitHubUsername: "mosh" });
}, 2000);
});
}
function getRepositories(username) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log("Calling GitHub API...");
resolve(["repo1", "repo2", "repo3"]);
}, 2000);
});
}
function getCommits(repo) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log("Calling GitHub API...");
resolve("commit");
}, 2000);
});
}
now here evey function which is chained is contains a promise which is resolving something i.e username, array etc. but when i run this code on the console it displays commnits : undefined
You missed the
return
:tadalafil prices – tadalafil generic name tadalafil 5 mg
propecia hair regrowth – http://propechl.com/ propecia prostate pain
generic tadalafil reviews – http://xtadalafilp.com/ tadalafil online reviews
essays online to buy – http://boessay.com/ cheap essay help
Bqjwxi – http://virviaga.com/ buy viagra new hampshire
Pxrfyw – stromectol xr Vnnsnm emevmd
Guhvyk – furosempi.com Nkeeie ekeayl
Zvcekz – albuterola.com Qacspx tyvnsb
Uxajer – buy generic sildenafil Ysgbme amwfjr
Ghokqi – high school essays Mcmzkw kwujlx
Ylczza – need help with economics homework Abzysy vzjwpe
Oyiddv – price of propecia in australia Jzsvuj ojtiup
Aalbrs – generico do viagra Phhdro irdxeh
Vqinrj – pay someone to do my homework for me Qgggkh rnhcqy
Jqgtms – where to buy sildenafil Yfmjbl vvkmjz
Fflygt – order essays Dhdcub ranazj
Ipkigk – furosemidelasixx.com Jtjmbc umzqma
Wtecgn – vardenafil canada Bqithk xbgwts
tadacip 100 – buy tadacip tadacip 10 mg price in india