Skip to content

Instantly share code, notes, and snippets.

@listiani13
Created January 30, 2018 16:01
Show Gist options
  • Save listiani13/e16389ced4d7c28b010ab27c83f9f912 to your computer and use it in GitHub Desktop.
Save listiani13/e16389ced4d7c28b010ab27c83f9f912 to your computer and use it in GitHub Desktop.
Fetching data from github API
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);
});
});
}
@sstur
Copy link

sstur commented Jan 30, 2018

See if you can do it with Promise.all()

@sstur
Copy link

sstur commented Jan 30, 2018

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