typescript-rest icon indicating copy to clipboard operation
typescript-rest copied to clipboard

How to respond with error and an error entity JSON inside response body

Open sryzycki opened this issue 7 years ago • 2 comments

Question...

Is there a way to build an endpoint that responds with 400 Bad Request and the following inside of the request response body?

{
 "errors": [
    {"field": "customParam", "message": "It is wrong" }
  ]
}

PS Great library, nice work! 👍

sryzycki avatar Oct 31 '18 09:10 sryzycki

You should be able to do it the standard express way:

res.status(400).send({ errors: [{ fields: "param", message: "SO wrong!" }] })

mautematico avatar Nov 08 '18 16:11 mautematico

HI, take a llok at this

thiagobustamante avatar Dec 27 '18 13:12 thiagobustamante