File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- export const AXIOS_INSTANCE_TOKEN = 'AXIOS_INSTANCE_TOKEN' ;
1+ export const AXIOS_INSTANCE_TOKEN = 'AXIOS_INSTANCE_TOKEN' ;
2+ export const HTTP_MODULE_ID = 'HTTP_MODULE_ID' ;
Original file line number Diff line number Diff line change 11import axios , { AxiosRequestConfig } from 'axios' ;
22import { Module } from '../decorators/modules/module.decorator' ;
33import { DynamicModule } from '../interfaces' ;
4- import { AXIOS_INSTANCE_TOKEN } from './http.constants' ;
4+ import { randomStringGenerator } from '../utils/random-string-generator.util' ;
5+ import { AXIOS_INSTANCE_TOKEN , HTTP_MODULE_ID } from './http.constants' ;
56import { HttpService } from './http.service' ;
67
78@Module ( {
8- providers : [ HttpService , {
9- provide : AXIOS_INSTANCE_TOKEN ,
10- useValue : axios ,
11- } ] ,
9+ providers : [
10+ HttpService ,
11+ {
12+ provide : AXIOS_INSTANCE_TOKEN ,
13+ useValue : axios ,
14+ } ,
15+ ] ,
1216 exports : [ HttpService ] ,
1317} )
1418export class HttpModule {
1519 static register ( config : AxiosRequestConfig ) : DynamicModule {
1620 return {
1721 module : HttpModule ,
18- providers : [ {
19- provide : AXIOS_INSTANCE_TOKEN ,
20- useValue : axios . create ( config ) ,
21- } ] ,
22+ providers : [
23+ {
24+ provide : AXIOS_INSTANCE_TOKEN ,
25+ useValue : axios . create ( config ) ,
26+ } ,
27+ {
28+ provide : HTTP_MODULE_ID ,
29+ useValue : randomStringGenerator ( ) ,
30+ } ,
31+ ] ,
2232 } ;
2333 }
2434}
You can’t perform that action at this time.
0 commit comments