E
E
Elena2020-08-27 18:45:40
Express.js
Elena, 2020-08-27 18:45:40

How to simulate a 500 error?

Hello! There is such a function:

module.exports.postUser = (req, res) => {
  const { name, about, avatar } = req.body;
  User.create({ name, about, avatar })
    .then(user => res.send(user))
    .catch((e) => res.status(500).send(e));
};

on the client side, the data is filled in and gets into this function. How can I make it give the server an error? I can get a client error, but I don’t know what needs to be broken in the server code so that it gives an error

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question