Skip to content

Instantly share code, notes, and snippets.

@toddzebert
Last active March 8, 2017 05:01
Show Gist options
  • Save toddzebert/31ab0c2ff1fe6c449ae63b2272858a51 to your computer and use it in GitHub Desktop.
Save toddzebert/31ab0c2ff1fe6c449ae63b2272858a51 to your computer and use it in GitHub Desktop.
Nested Async Callback example w/"all" pattern - check the console log
// requires https://gist.github.com/toddzebert/7c0aa1f1ee3be2d39d301bd875fead25
// requires https://gist.github.com/toddzebert/ef155ae58efb5a3788a7b143b0f7d215
var posts = [], data = { id: 4 };
getAuth(data, function (res) {
data.auth = res;
getProfile(data, function (res) {
data.profile = res;
getFeed(data, function (res) {
data.feed = res;
var getPosts = data.feed.map(post => getPost(post));
all(getPosts, function(res) {
data.posts = posts;
console.log(data);
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment