Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var doSomething = function() {
  2.    getDataFromAPI(function(result) {
  3.         var funcs = [];
  4.         results.forEach(function(value) {
  5.             var func = function valueQuery(callback) {
  6.                 mysql.query('some good sql query to do or whatever.', callback);
  7.             };
  8.            
  9.             funcs.push(func);
  10.         });
  11.        
  12.         async.parallel(funcs, function(err, ok) {
  13.             if (err) {
  14.                 // Do something with error.
  15.                  return 'back to home';
  16.             }
  17.            
  18.             console.log(ok);    // Array with 0 indexed results of each "value" variable result returned by mysql.
  19.         });
  20.    });
  21. }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement