Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

NestJS HTTP Module needs to be imported in every feature module

In nestjs the http module needs to be imported into every feature module. Is there any way to import the http module only once throughout the full application?

Although in all the feature modules the http configurations are the same, why do we need to import and configure in each one.

Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You could make a global module that imports it and exports it like so:

@Global()
@Module({
  imports: [HttpModule.register(httpModuleOptions)],
  exports: [HttpModule],
})
export class GlobalHttpModule {}

Now import it in the AppModule and you can use HttpService anywhere

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading