Closed abhishekp1996 closed 5 years ago
Are you using errors()
? If so, yes, the response when a celebrate errors happens is going to be a JSON object which explains why you're seeing object Object
. It is up to the consumer (you in this case) to display an HTML page formatted as you'd like if that's what you want.
If you're not using errors()
, then you're likely seeing the default Express error handler and again, it responds with HTML rather than JSON if I recall correctly.
@arb I was not using errors()
and Express was picking up their default error handler. Actually there was error handler in place, but I was using only 3 parameters for error handler - err
, request
, response
. When I added next
the code started working correctly. Thank you! I am celebrating
node
version - 10.16.0celebrate
version - 10.0.1joi
version (vianpm ls --depth=0 | grep joi
) - 15.0.3My
joi
schema looks like this:{email: Joi.string().trim().email()}
Here is an example value that is not working as expected:
a
The issue I am having with
celebrate
is:The issue is that whenever I hit the API, the validation kicks in and if the validation is failed, a HTML page is returned with nothing but
object Object
in the body and also in console the same thing is printed.But when the validation format are correct, everything is working good.
What could be wrong?