nest icon indicating copy to clipboard operation
nest copied to clipboard

[Documentation] ID issue

Open alexcorvi opened this issue 9 years ago • 3 comments

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.

alexcorvi avatar Apr 11 '17 11:04 alexcorvi

you can use

@Get() or @Get('/:id')

juandav avatar Apr 11 '17 11:04 juandav

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.

kamilmysliwiec avatar Apr 11 '17 13:04 kamilmysliwiec

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.

lock[bot] avatar Sep 25 '19 13:09 lock[bot]