Skip to content
Advertisement

how to send error codes in nestjs app from controller?

How can i send error codes in nestjs apart from 200? i tried to inject response object in a method but there is no method to send error.

save(@Body() body: any, @Res() response: Response): string {
    console.log("posting...")
    console.log(body)
    return "saving " + JSON.stringify(body)
}

the above code send body with 20X status i want to send different status code like 400 or 500.

Advertisement

Answer

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement