I got this error about AxiosRequestConfig, it's really specific, but still can't find in Google. Any tips? thanks
Argument of type 'AxiosRequestConfig' is not assignable to parameter of type 'AxiosRequestConfig<any>'.
  Types of property 'adapter' are incompatible.
    Type 'import("/Users/apple/Dev/back-end-api/node_modules/axios/index").AxiosAdapter' is not assignable to type 'import("/Users/apple/Dev/back-end-api/node_modules/@nestjs/axios/node_modules/axios/index").AxiosAdapter'.
      Types of parameters 'config' and 'config' are incompatible.
        Type 'AxiosRequestConfig<any>' is not assignable to type 'AxiosRequestConfig'.
          Types of property 'transitional' are incompatible.
            Type 'import("/Users/apple/Dev/back-end-api/node_modules/@nestjs/axios/node_modules/axios/index").TransitionalOptions' is not assignable to type 'import("/Users/apple/Dev/back-end-api/node_modules/axios/index").TransitionalOptions'.
              Property 'silentJSONParsing' is optional in type 'TransitionalOptions' but required in type 'TransitionalOptions'.
My code is like below, a simple AxiosRequestConfig, and Visual Studio Code flags the param config in this.httpService.get<LoginResponse>(MAILAPI_LOGIN_PATH, config)
 private _loginAndChangeToken(): Observable<LoginResponse> {
    const config: AxiosRequestConfig = {
      auth: {
        username: MAILAPI_USERNAME,
        password: MAILAPI_PASSWORD,
      },
    };
    return this.httpService.get<LoginResponse>(MAILAPI_LOGIN_PATH, config).pipe(
      map((response) => response.data),
      tap(({ token }) => {
        this.token = token;
      }),
    );
  }
I'm using NestJs axios, and the dependency is:
"@nestjs/axios": {
      "version": "0.0.3",
      "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-0.0.3.tgz",
      "integrity": "sha512-Cc+D2S2uesthRpalmZEPdm5wF2N9ji4l9Wsb2vFaug/CVWg2BoegHm0L1jzFUL+6kS+mXWSFvwXJmofv+7bajw==",
      "requires": {
        "axios": "0.23.0"
      },
Just use InternalAxiosRequestConfig instead of AxiosRequestConfig
Here for anyone needs: turned out the axios verion in my package.json is different from my teammate's. I deleted all my node modules, made sure I use the correct package.json file and did a clean install via
npm ci and it worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With