Hi,
I'm creating a CRUD project (with auth) using react and redux toolkit.
I have a header with token to give authorization.
What I can't understand is that header "config" with token is working without issues inside some services, but not in others.
For example, my postService to update a post is :
I get an error inside postService "
"{\"error\":{\"name\":\"JsonWebTokenError\",\"message\":\"jwt malformed\"}}" .
However, I use the same header config everywhere else (create or delete post, likes, comments). Backend is working without problem. Token is stored in LS, so it's just a problem with my service (or .addCase inside slice).
I can't comprehend why in some services it works with http://localhost:8080/api/comments/${PostId} and others http://localhost:8080/api/${postData?.PostId}.
I make it works in different services by tweaking, but can't understant why it's not working in the same way everywhere.
Hi, I'm creating a CRUD project (with auth) using react and redux toolkit. I have a header with token to give authorization. What I can't understand is that header "config" with token is working without issues inside some services, but not in others. For example, my postService to update a post is :
The postSlice:
And the Component "updatePost":
I get an error inside postService " "{\"error\":{\"name\":\"JsonWebTokenError\",\"message\":\"jwt malformed\"}}" . However, I use the same header config everywhere else (create or delete post, likes, comments). Backend is working without problem. Token is stored in LS, so it's just a problem with my service (or .addCase inside slice). I can't comprehend why in some services it works with
http://localhost:8080/api/comments/${PostId}
and othershttp://localhost:8080/api/${postData?.PostId}
. I make it works in different services by tweaking, but can't understant why it's not working in the same way everywhere.