Question: I have the below middleware validating the input with joi, when it catches an issue it does send back the status of 400 but I cant see the err,details in the chrome network tab. I have tried .send and .json

```
static validateResendEmail = async (req: Request, res: Response, next: NextFunction) => {
    const schema = Joi.object().keys({
      jwtToken: Joi.string().trim().required(),
    });
    const jwtToken = req.body.jwtToken;
    Joi.validate({ jwtToken }, schema, (err, val) => {
      if (!err) {
        req.body = val;
        next();
      } else res.status(400).send(err.details);
    });
  };

```

Answer: 
You can get error details like this:

```
static validateResendEmail = async (req: Request, res: Response, next: NextFunction) => {
    const schema = Joi.object().keys({
        jwtToken: Joi.string().trim().required(),
    });
    const jwtToken = req.body.jwtToken;
    const {
        error
    } = Joi.validate({
        jwtToken
    }, schema);

    if (!error) {
        req.body = val;
        return next();
    }

    const { message, context } = error.details[0];

    res.status(400).send(message);

    // res.json({
    //     message,
    //     status: 'fail',
    //     field: context.key
    // });
};

```
```
  var data = req.body;
cosnt schema = Joi.object().keys({
jwtToken: Joi.string().trim().required()
});

Joi.validate(data, schema, (error, value) => {
if(error) {
  res.status(400).json({
    "msg": error.message
  });
}

```

Try this!