Skip to content

Instantly share code, notes, and snippets.

@JacobHsu
Created November 3, 2014 08:06
Show Gist options
  • Save JacobHsu/184808d4dd255bdca501 to your computer and use it in GitHub Desktop.
Save JacobHsu/184808d4dd255bdca501 to your computer and use it in GitHub Desktop.
#nodejs async.waterfall callback
require('./waterfallexports')(req.body, function (result) {
console.log('[router] '+result);
});
var async = require('async');
var url = require("url");
module.exports = function (postReq, my_callback){
async.waterfall([
function(callback){
console.log('one');
callback(null, 'one', 'two');
},
function(arg1, arg2, callback){
console.log('three');
callback(null, 'three');
},
function(arg1, callback){
// arg1 now equals 'three'
console.log('done');
callback(null, 'done');
}
], function (err, result) {
// result now equals 'done'
console.log('waterfalldone');
var fileName = url.parse(postReq.fileurl).pathname.split('/').pop();
my_callback('fileName=' + fileName);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment