Skip to content

@tanstack/react-query access the Response object globally and for invidiual queries #3628

@JorrinKievit

Description

@JorrinKievit

Description

I have a few use cases where I want to access the response object (status code, headers, etc). For example in the global QueryClient onError callbacks, but also in specific queries.

Currently the only thing it returns is the parsed error response body, which does not allow these things. I understand that its nice developer UX to have typesafe error responses if defined in the schema, but this way im not able to get the original Response. Is there a way to do this? Any workarounds?

I have seen this #2070 (comment) originated from #2935, would work as a "hack" for invidiual queries but not globally.

If this is something we can explore, im also willing to try and create a PR for this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions