我无法获得MyOtherService
的上下文引用。
在docs之后,这是我的代码:
@Injectable()
export class MyService {
constructor(private readonly myOtherService: MyOtherService) {}
@Cron(CronExpression.EVERY_10_SECONDS)
async test() {
this.myOtherService.someMethod() //myOtherService is undefined;
}
}
答案 0 :(得分:1)
听起来您使用REQUEST
范围具有依赖项,由于没有使用请求,因此无法在CRON中实例化该依赖项。一切都必须是单例(DEFAULT)范围。