Redux RTK Query- TypeScript error. #3237
prasadbeligalage
started this conversation in
General
Replies: 1 comment 2 replies
-
https://redux-toolkit.js.org/rtk-query/usage-with-typescript#type-safe-error-handling |
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