【发布时间】:2020-12-15 19:31:49
【问题描述】:
我尝试将configService 添加到 JwtStrategy:
constructor(readonly configService: ConfigService) {
super({
//...
secretOrKey: this.configService.get('SECRET_KEY'),
});
}
我正在使用这个instruction。但是 TS 给我报错:
'super' 必须在 a 的构造函数中访问 'this' 之前调用 派生类。
当我删除 this(就像在这个 answer 中一样)时,Nest 返回另一个错误:
Nest 无法解析 JwtStrategy (?) 的依赖关系。请做出来 确保索引 [0] 处的参数 ConfigService 在 AuthModule 上下文。
【问题讨论】: