Skip to content

Conversation

@farnabaz
Copy link
Member

@farnabaz farnabaz commented Feb 3, 2021

Update return types of interceptor functions to match axios interceptor and module logic.
The interceptor implementation provide possibility to return config.

// https://github.com/nuxt-community/axios-module/blob/master/lib/plugin.js#L24
onRequest(fn) {
 this.interceptors.request.use(config => fn(config) || config)
},

Also Axios interceptors can support async callbacks. And reject handlers can return any type not just AxiosError

// https://github.com/axios/axios/blob/master/index.d.ts#L125
export interface AxiosInterceptorManager<V> {
  use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
  eject(id: number): void;
}

export interface AxiosInstance {
  interceptors: {
    request: AxiosInterceptorManager<AxiosRequestConfig>;
    response: AxiosInterceptorManager<AxiosResponse>;
  };
}

resolves #441

@codecov
Copy link

codecov bot commented Feb 3, 2021

Codecov Report

Merging #476 (9b4d043) into master (62f17ca) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #476   +/-   ##
=======================================
  Coverage   88.23%   88.23%           
=======================================
  Files           1        1           
  Lines          51       51           
  Branches       27       27           
=======================================
  Hits           45       45           
  Misses          6        6           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62f17ca...18f02c3. Read the comment docs.

@pi0 pi0 merged commit ecfab9a into master Feb 8, 2021
@pi0 pi0 deleted the interceptors-type branch February 8, 2021 21:39
This was referenced Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extended Axios.AxiosRequestConfig from #408 breaks interceptor types

3 participants