This one works, and each function is producing very different results and using each others results as well. So how do I collect all these results?
findBank
.then(findAllReceipts)
.then(findAllExpense)
.then(res.json({error:false, "bank":bankArray, "receipt":receiptArray, "expense":expenseArray}))
.catch(err => {
res.json({error:true,err})
});
The functions are full of promise arrays so thats not the ideal place to do it
I know that promises will parse data to each other, but is there a way to make it pass it to arrays too?
This one does not work:
bankArray = findBank
.then(receiptArray = findAllReceipts)
.then(expenseArray = findAllExpense)
.then(res.json({error:false, "bank":bankArray, "receipt":receiptArray, "expense":expenseArray}))
.catch(err => {
res.json({error:true,err})
});
This one does not work:
findBank
.then(bankArray = data)
.then(findAllReceipts)
.then(receiptArray = data)
.then(findAllExpense)
.then(expenseArray = data)
.then(res.json({error:false, "bank":bankArray, "receipt":receiptArray, "expense":expenseArray}))
.catch(err => {
res.json({error:true,err})
});
Is there any way to do this? Or do I have to create a function between each .then that moves the data to the arrays? (seems a bit stupid to me, but I have no other idea right now)
via torbenrudgaard
No comments:
Post a Comment