I am getting the following error in nodejs and expressjs, the code is given below

```
module.exports.forgotPassword = async (req, res) => {
  try {
    const email = req.body.email;
    const user = await User.findOne({ email: email });
    console.log(user);
    if (user === null) throw new Error("Please register first");
    if (user !== null) {
      const id = user[0]._id.toHexString();
      const token = crypto.randomBytes(64).toString("hex");
      let link = `${id}/${token}`;
      res.status(200).send(link);
    }
  } catch (err) {
    res.status(401).send({ error: err.message });
  }
};

```