In the code below I have an object list named foundUser. I insert data into it and at the very bottom of the code I print it in the console and it shows as empty. I have been trying to figure this out for hours now and I am unable to find a solution. Any help will be greatly greatly appreciated.
addUser: (req, res) => {
  const body = req.body;
  let errors = {};
  let foundUser = {};
  pool.query('SELECT email from registration WHERE email = ?', [body.email], (error, result) => {
    if (error) {
      console.log(error);
    }
    if (result.length > 0) {
      pool.query('SELECT id, name, email from registration WHERE email = ?', [body.email], (error, result) => {
        if (error) {
          console.log(error)
        } else {
          var toString = JSON.stringify(result)
          var toJSON = JSON.parse(toString)
          foundUser.id = toJSON[0].id
          console.log(foundUser);
          req.body.supplier_id = foundUser.id//The object value inserted in foundUser is not being assigned to req.body.supplier_id
        }
      })
    }
    console.log(foundUser) // In my console it shows as empty.
    //I want to then take the object inserted in founderUser and assign it to a field in mySQL but I cant since foundUser is empty
  })
}
