Catch 401 error
Hi, how can i catch a 401 error and redirect to a specific page, by default it goes to the login page. I want to show some kind of message/notification when i get 401 error , different from the base notification from the notification provider.
9 Replies
continuing-cyan•2y ago
Hi 👋 .
You can use this for custom redirectPath. also you can add name and message for noification
xenial-black•2y ago
For some reason this doesn't work.
These are the versions i use, if it matters
"@pankod/refine-antd": "^3.62.0",
"@pankod/refine-core": "^3.88.0",
"@pankod/refine-react-router-v6": "^3.36.2",
"@pankod/refine-simple-rest": "^3.35.0",
continuing-cyan•2y ago
Sorry for your trouble. i will debug and return you as soon as possible
xenial-black•2y ago
Ok, thank you
continuing-cyan•2y ago
can you try this ? simple-rest using axios. and axios returns status in response object
xenial-black•2y ago
Yes, this work,i can catch the 401 error, but the redirect doesn't seem to work
I'm looking at the documentation here https://refine.dev/docs/api-reference/core/hooks/auth/useCheckError/
but when i reject the promise , every time it goes to the /login page
continuing-cyan•2y ago
Sorry, my first code example was wrong. i reproduced this code. it goes here as expected. https://hgdwf9.csb.app/login?error=401
you can check project here : https://codesandbox.io/s/hardcore-golick-wrnrom?file=/src/App.tsx
can you update refine core to latest version ? probably this bug fixed in here https://github.com/refinedev/refine/commit/e3642eafa215e354f605c57ec380bc04e1c27812
xenial-black•2y ago
I updated the version and it works now, thank you !
continuing-cyan•2y ago
I'm glad to hear that 🙏