I am using AWS Websocket API Gateway. I have the following code in lambda and I want to return error to connected users
// Joi Validation
const { error, value } = bodySchema.validate(body);
if (error) {
return callback({ statusCode: 400, body: "Invalid request" });
}
But the connected user gets:
{"message": "Internal server error", "connectionId":"YT8ZZe4sBcwCGvA=", "requestId":"YT8cqFb3BcwFgVA="}
What do I do. I want errors to be sent properly. With statusCode and body.