react-redux-jwt-auth-example
react-redux-jwt-auth-example copied to clipboard
Why do you call a payload data a token?
Here is an operation from https://github.com/joshgeller/react-redux-jwt-auth-example/blob/master/src/actions/index.js#L63.
In decoded
varibale in not a token. It is only a payload object which is only one third of a token.
let decoded = jwtDecode(response.token); // decoded in not a token. It is a payload object only!
dispatch(loginUserSuccess(response.token));
And in loginUserSuccess
action you have:
export function loginUserSuccess(token) {
localStorage.setItem('token', token); // why token? It is not a token, it is a payload object
return {
type: LOGIN_USER_SUCCESS,
payload: {
token: token
}
}
}
Why do you call a payload data a token?
No idea if I am right or not, but the response is the JSON value returned from the server..
In this case, { token: '3fj39jf9j3f' }
I'm not sure why he has the jwtDecode line in there, as he never ends up using decoded. Thus it is actually the token, and also you can really pass in any object key into the action object. I'm guessing payload is just a common word for the 'data' embedded in an action.