Thursday, 18 May 2017

Nodejs send multiple results with the same res.json

I have a large nodejs controller doing a lot of mongodb work, and I want it to send several different json results back to caller (my angular controller).

findAllBanks
    .then(findAllReceipts)
    .then(findAllTransactions)
    .then(res.json({error:false, bankArray + receiptsArray + transactionArray}))
    .catch(err => {
        console.log("getbankAccountReport ERR: " + err);
        res.json({error:true,err})
    })

Unfortunately all 3 result arrays are different.

Any ideas how to do this?



via torbenrudgaard

No comments:

Post a Comment