-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nest can't resolve dependencies of the TELEGRAM_MODULE_OPTIONS #332
Comments
I got the same did any one solve this problem ? |
To use async module import like this: TelegramModule.forRootAsync({
useFactory: async (configService: ConfigService) => ({
botKey: configService.get('BOT_TOKEN'),
}),
inject: [ConfigService],
}), You need to make your config service globally visible, so in AppModule just add @Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
],
providers: [AppService],
})
export class AppModule {} |
I tried this way and no more error: @Injectable()
export class HookTelegramService {
private readonly telegram: TelegramService
async sendMessage(sendMessageParam: TelegramSendMessageParams): Promise<TelegramMessage> {
const result = await this.telegram.sendMessage(sendMessageParam).toPromise()
return result
}
} Move |
I tried to use export class HookTelegramService implements OnModuleInit {
private readonly logger = new Logger(HookTelegramService.name)
private telegram: TelegramService
constructor(private moduleRef: ModuleRef) {}
onModuleInit() {
this.telegram = this.moduleRef.get(TelegramService, { strict: false })
}
async sendMessage(sendMessageParam: TelegramSendMessageParams): Promise<TelegramMessage> {
const result = await this.telegram.sendMessage(sendMessageParam).toPromise()
return result
}
} |
you have to inject the service.
|
I removed the TelegramService from exports and providers and the error disappeared. |
you need to change your async import to include the ConfigModule:
|
Hi, when I follow steps from the readme I got following error:
The text was updated successfully, but these errors were encountered: