NestJS · Junior · Question 34 of 75
How do you return a 404 from a service or controller?
- 1
return 404 - 2
res.status(404)is the only way - ✓Correct answer:
throw new NotFoundException('User not found')
Explanation
Nest's built-in exception layer turns HttpException subclasses into JSON responses with the right status code.