Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Demystifying Async Programming in Javascript - fetchJson async generator
co(function* () {
var user = yield fetchJson('/api/user/self');
var interests = yield fetchJson('/api/user/interests?userId=' +;
var recommendations = yield Promise.all( => fetchJson('/api/recommendations?topic=' + i)));
render(user, interests, recommendations);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.