#Endpoint Returning Undefined Token

1 messages · Page 1 of 1 (latest)

outer plover
#

I'm guessing this is on the core package. I've tried multiple methods of trying to capture the token, but it keeps returning as undefined and throws an error saying that the token is not a string. Any ideas on how to resolve?

#

We tried using a DTO here, that only had token: string; but that failed too. It wasn't until we dropped the DTO and went with string that we actually got the errors.

// route: /account
@Controller('account')
export class AccountController {
  constructor(private accountService: AccountService) {}

  // route: /account/:token
  @UseGuards(JWTGuard)
  @Post('/:token')
  accountRetrieve(
    @Param(':token') token: string,
    @Request() req,
    @Res({ passthrough: true }) res
  ) {
    console.log('token', data);
    return this.accountService.retrieve(token, req, res);
  }
}
#

We tried also sending the token in the body, but didn't get anywhere with it.

    // route: /account/:token
    @UseGuards(JWTGuard)
    @Post()
    accountRetrieve(@Body() data: string) {
        console.log('token', data);
        return this.accountService.retrieve(data);
    }
#

Before anyone asks, we have other endpoints using the @Param method with dynamic data. It works just fine. The only difference here is that we don't have any other data being sent in the body.

    // route: /account/password-reset/:id
    @Patch('password-reset/:token')
    accountPasswordReset(
        @Param(':token') token: string,
        @Body() data: AccountPasswordResetDTO,
        @Request() req,
        @Res({ passthrough: true }) res
    ) {
        return this.accountService.passwordReset(token, data, req, res);
    }
outer plover
#

When the DTO is removed and replace with string, we get the below error.