Skip to content

Instantly share code, notes, and snippets.

@toddzebert
Last active March 27, 2017 04:08
Show Gist options
  • Save toddzebert/c9d75cd901897e7363bf142a90a2b2a1 to your computer and use it in GitHub Desktop.
Save toddzebert/c9d75cd901897e7363bf142a90a2b2a1 to your computer and use it in GitHub Desktop.
getPosts code for use with getPost.js, and simAsync.js
// requires https://gist.github.com/toddzebert/996e297c1c081d19378eaf5f29dc75bb
// requires https://gist.github.com/toddzebert/9dc7de3ed0195dfefcc533bcba426930
var getPosts = function (data) {
return new Promise( (resolve, reject) => {
const getAllPosts = data.feed.map(post => getPost(post));
Promise.all(getAllPosts)
.then(result => {
data.posts = result; resolve(data);
})
.catch(result => {
data.posts = result; reject(data);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment