I have created the api with route api/login, I have client in server folder so it can be the url without http (I have proxy for that). The problem is when I submit the request. I have 500 error in browser(from catch(error) ). Here is my action creater:
export const loginUser = (email,password) => {
return function(dispatch) {
// const token = 'my secret token', I dont know where to put it
axios.post(
'api/login', {email: email, password: password}
).then((response) => dispatch({type: LOGIN_USER, payload:response}))
.catch((error) => {
console.log("axios error:",error);
});
}
}
In submit function in React I have email and password as a state, so I pass it into action. I am not sure what I have to put in axios, I suppose I need to add by secret token from jwt?
I really appreciate any advises. Thank you in advance.