node.js - How to fix AXIOS_INSTANCE_TOKEN at index [0] is available in the Module context

ID : 274558

viewed : 23

Tags : node.jsaxioshttprequestnestjshttpservicenode.js





Top 3 Answer for node.js - How to fix AXIOS_INSTANCE_TOKEN at index [0] is available in the Module context

vote vote

92

Import HttpModule from @nestjs/common in TimeModule and add it to the imports array.

Remove HttpService from the providers array in TimeModule. You can directly import it in the TimeService.

import { HttpModule } from '@nestjs/common'; ...  @Module({     imports: [TerminalModule, HttpModule],     providers: [TimeService],     ... }) 

TimeService:

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

If your response type is an Observable of type AxiosResponse, then import these two as well in the service file TimeService.

import { Observable } from 'rxjs'; import { AxiosResponse } from 'axios'; 

For reference, check out http-module and this post.

vote vote

85

Don't pass HttpService in the providers. Import only HttpModule.

vote vote

75

Top 3 video Explaining node.js - How to fix AXIOS_INSTANCE_TOKEN at index [0] is available in the Module context







Related QUESTION?