Nest.js axios HttpModule冻结应用初始化

56lgkhnf  于 12个月前  发布在  iOS
关注(0)|答案(1)|浏览(116)

我有一个模块是这样的:

import { Module } from '@nestjs/common'
import { OtpService } from '@modules/auth/otp/otp.service'
import { OtpResolver } from '@modules/auth/otp/otp.resolver'
import { HttpModule } from '@nestjs/axios'

@Module({
  providers: [OtpResolver, OtpService],
  imports: [
    HttpModule.register({
      timeout: 5000,
      baseURL: "some url"
    }),
  ],
})

export class OtpModule {}

字符串
然后导入到app模块中:

import { OtpModule } from '@modules/auth/otp/otp.module'

@Module({
  imports: [
    ....
    OtpModule,
    GraphQLModule.forRootAsync({
      useClass: GraphqlConnectionService,
    }),
  ],
  providers: [AppConfigService],
})

export class AppModule {}


一切工作,如果我删除otp模块,它也工作,如果HttpModule没有导入那里.我是通过this教程,但id似乎不工作.任何关于如何解决这个问题的想法将是非常有帮助的.
UPD:它只是冻结在init上,这里是输出日志,所有其他模块都正确初始化,当涉及到otp时,它只是停止在那里

{"level":"info","message":"TypegooseModule dependencies initialized"}
{"level":"info","message":"TypegooseModule dependencies initialized"}
{"level":"info","message":"TypegooseModule dependencies initialized"}
{"level":"info","message":"TypegooseModule dependencies initialized"}
{"level":"info","message":"GraphQLModule dependencies initialized"}

1qczuiv0

1qczuiv01#

我通过从@nestjs/axios导入HttpService和HttpModule修复了它
更换

import { Injectable, HttpService } from '@nestjs/common';

字符串
为此

import { HttpService } from '@nestjs/axios';

相关问题