Cmag
Cmag

Reputation: 15750

JavaScript module.exports callbacks

Folks, How do I get the results from Y back to the Z function?

code:

module.exports = {

    Z: function (req) {
        var x = req.body
        function getX (results) {
            console.log (results)
        }
        module.exports.Y(x, getX())
    },

    Y: function (x, upstreamCallback) {
        var locals = new Array();
        async.parallel([
            function a(callback) {
            },
            function b(callback) {
            },
        ], function (err) {
           console.log(locals)
           upstreamCallback(locals)
        })
    },
}

locals are being called properly, they are showing up in the console. Problem is that locals are not being passed back to the Z...

Thanks!

Upvotes: 0

Views: 901

Answers (1)

Katana314
Katana314

Reputation: 8610

Not a NodeJS person, but my highly educated guess is that you're intending to pass getX, not call it. If you remove the parentheses, it's passed in, and should then be called in Y as upstreamCallback.

Upvotes: 4

Related Questions