Redux RTK Query- TypeScript error. #3237
octopus-travels
started this conversation in
General
Replies: 2 comments 4 replies
-
|
https://redux-toolkit.js.org/rtk-query/usage-with-typescript#type-safe-error-handling |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
@phryneas don't you tired to answer same answers to people who is struggling to handle API errors with RTK query? maybe it's time to provide a way to type API errors for developers in their own style? I understand that it's not easy to do backward-compatible, but maybe future major versions could have that? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When I try to check the error of the RTK query response, it gives the following TypeScript error.
Property 'error' does not exist on type 'FetchBaseQueryError | SerializedError'.
Property 'error' does not exist on type '{ status: number; data: unknown; }'.ts(2339)
Error occurs when accessing the "error" value of "error" object (error.error), however the console log works when threre's a network error.
const { data, error, isLoading } = useGetAllProductsQuery('products')if (error) {if (error.error === 'TypeError: Network request failed') {console.log('Network error')...Beta Was this translation helpful? Give feedback.
All reactions