Skip to content

Commit

Permalink
feat: support options.axiosInterceptorOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Nov 30, 2023
1 parent 20c7d3d commit 7a53a4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/interceptors/requestHeadersInterceptor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { isFunction } from '@varlet/shared'
import type { RequestInterceptor } from '../instance'
import type { AxiosInterceptorOptions } from 'axios'

export interface RequestHeadersInterceptorOptions {
headers?: Record<string, string> | (() => Record<string, string>)
axiosInterceptorOptions?: AxiosInterceptorOptions
}

export function requestHeadersInterceptor(options: RequestHeadersInterceptorOptions = {}): RequestInterceptor {
Expand All @@ -21,5 +23,6 @@ export function requestHeadersInterceptor(options: RequestHeadersInterceptorOpti
onRejected(error) {
return Promise.reject(error)
},
options: options.axiosInterceptorOptions
}
}
4 changes: 3 additions & 1 deletion src/interceptors/responseBlobInterceptor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { AxiosResponse } from 'axios'
import type { AxiosInterceptorOptions, AxiosResponse } from 'axios'
import type { ResponseInterceptor } from '../instance'

export interface ResponseBlobInterceptorOptions {
data?: (response: AxiosResponse<any, any>) => any
axiosInterceptorOptions?: AxiosInterceptorOptions
}

export function responseBlobInterceptor(options: ResponseBlobInterceptorOptions = {}): ResponseInterceptor {
Expand All @@ -17,5 +18,6 @@ export function responseBlobInterceptor(options: ResponseBlobInterceptorOptions
onRejected(error) {
return Promise.reject(error)
},
options: options.axiosInterceptorOptions,
}
}

0 comments on commit 7a53a4e

Please sign in to comment.