I'm planning to use async.waterfall with Bookshelf.js, but there's a problem. people.fetchAll is used with .then, so I have to write things inside of it. But what if I want to pass the values it return to another function? How can I do that? I want to use res.send() but I can't because it breaks after the first send, getting "can't set headers after they are sent" error.async.waterfall([ function(callback) { people.fetchAll().then(function(data) { data = data.toJSON(); console.log(data); // this works fine }); callback(null, 'one', 'two'); }, function(arg1, arg2, callback) { // I want to be able to use data here. callback(null, 'three'); } ], function (err, result) { // result now equals 'done' });
Submitted December 09, 2016 at 11:21AM by laraveling
No comments:
Post a Comment