How to pass Header JWT Token with Axios & React?
问题 I make web application with React, Express, MongoDB. And, I want to pass jwt token with header. But, I pass it, get 401 error (Unauthorized). In login actions.js : export function login(username, password) { return function(dispatch) { axios .post(`${API_URL}/auth/login`, { username, password }) .then(res => { dispatch(loginSuccess(res.data, username)); const token = res.data.token; axios.defaults.headers.common["Authorization"] = token; history.push("/"); }) .catch(err => { if (err.response