API integration

hey guys i need help anyone that have a good understanding on api integration using axios for login functionality can you help me on it the problem is i have login component and it have the email and password validation done including the necessary things for the login api call i have created a function here is what function looks like : https://gist.github.com/lost50U1/7caf97f84484ac631da1001efd724368 and when i check the devtools network tab the i am getting this response from the api backend { "success": true, "message": "You have logged in successfully.", "accessToken": "eyJhbGciOiJIUzI", "role": "supplier", "id": "6703bda7" } but it is not redirecting me to my welcome page other configurations of the project that might help: useUser.ts hook https://gist.github.com/lost50U1/7bb72d153c0eb63ea6f5573e6cb16e4e anyone that wants to help you can ask me anything about the project
Gist
users.ts
GitHub Gist: instantly share code, notes, and snippets.
Gist
useUser.ts
GitHub Gist: instantly share code, notes, and snippets.
4 Replies
vic
vic2mo ago
I'm not good at react and redux but the problem is maybe because u didn't add navigate('/welcomepage') on u r login function ? U set like if (status === 200) { token && dispatch(setToken(token)); if (token) { dispatch(setToken(token)); CacheItem(CachedItem.token, token, true); } But u didn't add navigate function here on status === 200 if(status === 200 ) { token && dispatch(setToken(token)) navigate('path') }
Lost Soul
Lost SoulOP2mo ago
i set all things related to path on another folder for it with a redirection functions and i think i need to show all of the codes if it's okay with you can i dm you and explain in detail
vic
vic2mo ago
Sure
Lost Soul
Lost SoulOP2mo ago
Thanks for the help it was token naming difference that comes from the api response it was accesstoken instead of token
Want results from more Discord servers?
Add your server