mlegenhausen / fetch-intercept

Interceptor library for the native fetch command inspired by angular http intercepts.
MIT License
406 stars 52 forks source link

TS Type mismatch when response is async function or returns promise #61

Open rkhaslarov opened 2 years ago

rkhaslarov commented 2 years ago

Type '(response: FetchInterceptorResponse) => Promise' is not assignable to type '(response: FetchInterceptorResponse) => FetchInterceptorResponse'.

export interface FetchInterceptor { request?(url: string, config: any): Promise<any[]> | any[]; requestError?(error: any): Promise; response?(response: FetchInterceptorResponse): FetchInterceptorResponse; responseError?(error: any): Promise; }

So, the example of refresh token is not usable with ts...

rkhaslarov commented 2 years ago

The example is here https://github.com/werk85/fetch-intercept/issues/39#issuecomment-813922758

gaspartripodiglobant commented 2 years ago

Check this https://github.com/werk85/fetch-intercept/issues/60#issuecomment-981971623