Skip to content

Instantly share code, notes, and snippets.

@Kikobeats
Created October 28, 2014 16:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kikobeats/bf0ee77573798628d7d7 to your computer and use it in GitHub Desktop.
Save Kikobeats/bf0ee77573798628d7d7 to your computer and use it in GitHub Desktop.
async wit coffee
# same code, with async
async = require 'async'
# all requests will be run in parallel
async.parallel [
(cb) -> $.get '/user/:id', cb
(cb) -> $.get '/country/:id', cb
(cb) -> $.get '/orders/:userId', cb
(cb) -> $.get '/relatedProducts/:userId', cb
], (err, results) ->
if err?
# deal with the error
else
[user, country, orders, relatedProducts] = results
# do something with the data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment