Typescript prepareHeaders and getState #3315
Replies: 7 comments 5 replies
-
I assume you have a CORS configuration that does not allow for an Also, you don't seem to be calling Generally: have you looked at this authentication example? |
Beta Was this translation helpful? Give feedback.
-
I believe so but am still quite new to redux
…On Sat, 1 Apr 2023 at 12:54, Lenz Weber-Tronic ***@***.***> wrote:
That error means that state.auth is undefined, so you cannot access
state.auth.accessToken. Did you really configure your auth reducer to be
at state.auth?
—
Reply to this email directly, view it on GitHub
<#3315 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQ37KPDO7V6LQRLSBFAEPGTW7AJQRANCNFSM6AAAAAAWPQ654U>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
did you solve it? I have a similar issue in my code |
Beta Was this translation helpful? Give feedback.
-
same problem, did you solve it? |
Beta Was this translation helpful? Give feedback.
-
Try to remove this credentials: 'include' from your apiSlice.ts |
Beta Was this translation helpful? Give feedback.
-
My code is similar, I removed the line "credentials: 'include'" from apiSlice.ts, and it works. You can see my code here: https://github.com/jefponte/3s-web In fact, I use your code as a model to make my own. |
Beta Was this translation helpful? Give feedback.
-
I had this issue but it was caused by an erroneous ApiProvider element in the App.tsx which overwrote the store and removed all the slices. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have been trying to learn Redux and RTK Query to manage the state of my app.
I have really struggled to add the logic to persist the login state. I planned to use prepareHeaders in my apiSlice.ts to store the access token once the user logs in but I don't seem to connect to my server and the token stays as undefined. Without the prepareHeaders option, my app seems to get the response ok (although pointless).
I would really appreciate it if anyone could look over my code and offer advice.
store.ts
apiSlice.ts
authApiSlice.ts
authSlice.ts
Beta Was this translation helpful? Give feedback.
All reactions