Response.cookie 未定义

Response.cookie is not defined

我是 NestJS and I'm using it to handle a rest API server. I'm trying to send some HTTP-only cookie in the response and I'm following the official documentation 的新手,它建议在 Response 对象中使用 cookie 方法,但看起来该方法未定义。这是我的代码:

@Get('login')
verifyLoginEmailCode(
  @Headers() { email, password }: LoginInputDto,
  @Res({ passthrough: true }) res: Response,
) {
  // as per official documentation res.cookie should be a function but it's not defined
  console.log(Object.keys(res)); // in the keys "cookie" is missing

  return this.authAdminService.login(email, password);
}

有没有错?

您应该正确导入它们。您应该从 @nestjs/common.

导入 Response from express 和 Req