Skip to content

fix issue when overwriting global interceptors #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/useFetchArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ export default function useFetchArgs(
...defaults.headers,
...globalOptions.headers,
...localOptions.headers
} as Headers
} as Headers,
interceptors: {
...defaults.interceptors,
...globalOptions.interceptors,
...localOptions.interceptors
} as Interceptors
} as Options
if (overwriteGlobalOptions) return overwriteGlobalOptions(finalOptions)
return finalOptions
Expand Down Expand Up @@ -79,7 +84,7 @@ export default function useFetchArgs(
}, [options])

const customOptions = useMemo((): CustomOptions => {
const customOptionKeys = Object.keys(useFetchArgsDefaults.customOptions) as (keyof CustomOptions)[] // Array<keyof CustomOptions>
const customOptionKeys = Object.keys(useFetchArgsDefaults.customOptions) as (keyof CustomOptions)[] // Array<keyof CustomOptions>
const customOptions = customOptionKeys.reduce((opts, key) => {
(opts as any)[key] = options[key]
return opts
Expand Down