Skip to content

Instantly share code, notes, and snippets.

@rlemon

rlemon/sample.js Secret

Created May 2, 2014 13:42
Show Gist options
  • Save rlemon/e8fdcf0e3c2d898a4a92 to your computer and use it in GitHub Desktop.
Save rlemon/e8fdcf0e3c2d898a4a92 to your computer and use it in GitHub Desktop.
foo(function(err, fres) {
var arr = [];
fres.forEach(function(item) {
bar(item, function(state) {
arr.push({ item: item, state: state });
});
});
res.render(page, { arr: arr });
// obviously arr is empty.
// how would I use promises to handle this?
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment