nest
nest copied to clipboard
[Documentation] ID issue
On this page You're looking for users using the find method, but the IDs are stored in the service as numbers and the received param will be a string. So here's a quick fix:
This:
@RequestMapping({ path: '/:id' })
getUser(req, res) {
this.usersService.getUser(req.params.id)
.then((user) => res.status(200).json(user));
}
Needs to change to this:
@RequestMapping({ path: '/:id' })
getUser(req, res) {
this.usersService.getUser(Number(req.params.id)) // simply casted to number
.then((user) => res.status(200).json(user));
}
I know it's just an example for demonstration purposes, but it should work nonetheless.
you can use
@Get() or @Get('/:id')
Hi @alexcorvi, You're right, thanks! I changed:
const user = await this.usersService.getUser(req.params.id);
to:
const user = await this.usersService.getUser(+req.params.id);
Now, it should works fine.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.