koajs / examples

Example Koa apps
4.52k stars 744 forks source link

Properties not working for ctx.throw #146

Closed rkoziel closed 3 years ago

rkoziel commented 3 years ago

Hello, I am trying to use the properties parameter with ctx.throw but I do not see the object added anywhere in the response. For example, if part of a request message is missing, I want to do something like the following:

if (!username) {
    return ctx.throw(400, 'Invalid request message', {
        validationErrors: {
            username: 'Username cannot be null',
        },
    });
}

When I try to do a console.log of the response, I see the status and message set properly but I do not see the validationErrors object in the response. Any suggestions on this are appreciated.