I have a few ctx.assert
in my code, something like:
ctx.assert(db && fb && ObjectId, 400, 'Email validation config error')
If that assert fails, my response will be "Email validation config error" as string
, but I would like to get a response in JSON
, I tried something like that but it doesn't work:
ctx.assert(db && fb && ObjectId, 400, {error: 'Email validation config error'})
Is there a way to make the response from ctx.assert
be in JSON
?
ctx.assert(db && fb && ObjectId, 400, JSON.stringify({error: 'Email validation config error'}))