Created
November 3, 2014 08:06
-
-
Save JacobHsu/184808d4dd255bdca501 to your computer and use it in GitHub Desktop.
#nodejs async.waterfall callback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('./waterfallexports')(req.body, function (result) { | |
console.log('[router] '+result); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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