I have an api that takes in a userId, finds the Item associated with that, then I need to find all Accounts associated with the itemId.
I keep getting [Promise <Pending>] when I console.log
Any clue how to resolve this?
router.get('/:userId', auth, async (req, res) => {
  try {
    const { userId } = req.params
    const items = await Item.find({
      userId: userId
    });
    const accounts = items.map(
      async item => {
        await Account.find({
          itemId: item.itemId
        })
    })
    console.log(items)
    console.log(accounts)
    res.json(accounts);
  } catch (err) {
    console.error(err.message);
    res.status(500).send('Server Error');
  }
});
 
    