Omar Martin
asked on
Receiving data from two (2) tables at the same time
I am trying to send the results for two(2) tables using sequelize, however only the results on either one table is printed. I would like both tables to print using promises. Here is the route code:
router.get("/alldataa", (req, res) =>
Promise.all([boilerHouse.findAll(), compressorHouse.findAll()])
.then((data) => {
res.render('gigs', {
gigs:data[0],
gigs:data[1],
//data[0] is response from tableA find
// data[1] is from tableB
})
})
.catch(err => console.log(err)));
ASKER
If I try them individually, the data which which is last is returned.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you...
You are welcome.
What do you get if you do a console.log(data) on line 5