Skip to content

Interceptors aren't chained #371

Open
@veloware

Description

Describe the bug
Interceptors aren't chained, in that global interceptors at the provider level, are overridden if an interceptor is introduced at the useFetch() hook level

There does seem to be a work around, at the hook level -

request: async ({ options }) => {
        globalOptions.interceptors?.request?.({ options });
        ...

However, that could easily be forgotten on a case per case basis, and is no different that just housing the 'global' interceptor code in a standard function, and just invoking that, which defeats the purpose of a global 'interceptor'

⚠️ Make a Codesandbox ⚠️
Please do this to easily reproduce the bug.

To Reproduce

  • introduce a request interceptor at the provider level, to say, add a request correlation-id header
  • introduce a request interceptor at the hook usage level, to say, add another request header
  • When running the hook, the provider level request interceptor does not run.

Expected behavior
Both should run, probably the global first, then the more specific interceptor at the hook level second

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions