Coding task · NestJS course · Module 1: NestJS Basics
GET Endpoint - Fetching Data
Write a GET endpoint that fetches a legionary by ID from the URL parameter.
Task
In a LegionController with the @Controller('legionaries') decorator, keep an array of legionaries, e.g. [{ id: 1, name: 'Marcus Aurelius' }]. Write a findOne method with @Get(':id') that reads the id through @Param('id') and returns the legionary with that id, and throws NotFoundException when there is none. Remember that the id from the URL is a string.