Reputation: 5762
I'm new in NestJS so I obviously do something wrong but can't figurate out what it is.
In same controller I've got route without text after it (/:id
) which works totally fine.
@Controller('channel')
export class ChannelController extends CrudController<Channel> {
constructor(
private readonly channelService: ChannelService,
private readonly videoService: VideoService
) {
super(channelService);
}
@Get()
async findAll(@Query() params): Promise<Pagination<Channel>> {
return this.channelService.findAll({take: params.take, skip: params.skip, relations: ['language']});
}
@Get('/:id')
async findOne(@Param('id') id) {
return this.channelService.findOne({relations: ['language']});
}
@Get('/:id/video')
async findVideosByChannelId(@Param('id') id) {
return this.channelService.findOne({relations: ['language']});
}
}
{"statusCode":404,"message":"Cannot GET /channel/3/video","error":"Not Found"}
Guys and idea or hint what I'm doing wrong is welcome.
Upvotes: 0
Views: 2823
Reputation: 629
Just like MorKadosh said, remove the slash because NestJS adds the first slash by default if you dont remove it your final endpoint will be somenthing like this:
http://localhost:3000/channel//:id
Upvotes: 2