Created
January 30, 2018 16:01
-
-
Save listiani13/e16389ced4d7c28b010ab27c83f9f912 to your computer and use it in GitHub Desktop.
Fetching data from github API
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
fetch('https://api.github.com/orgs/kodefox/repos') | |
.then((resp)=>{ | |
resp.json().then((data) => { | |
data.forEach((item)=>{ | |
fetchRepo(item.name); | |
}); | |
}) | |
}); | |
let fetchRepo = (name)=>{ | |
fetch('https://api.github.com/repos/kodefox/'+name) | |
.then((resp)=>{ | |
resp.json().then((data)=>{ | |
console.log(name, data.subscribers_count); | |
}); | |
}); | |
} |
Also, remember that you can return a promise from a then: .then(() => promise).then(...)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See if you can do it with Promise.all()