title: Passing JWT in headers with axios
body: <p>I've created a small project with a node back-end and react front-end to fetch the data through REST calls. I used <strong>Axios</strong> library, but when I pass the headers with it I keep getting an error saying:</p>
  
  <p><strong><code>Failed to load resource: the server responded with a status of 401 (Unauthorized)</code></strong>. </p>
  
  <p>I found out two methods and both did not work. They are: </p>
  
  <pre><code>export const getUsersDetails=()=&gt;{
    console.log('calling');
    return (dispatch) =&gt; {
      return axios.get('http://localhost:3030/users',{headers: { "Authorization": localStorage.getItem('jwtToken') }}).then((data)=&gt;{
                   console.log('data comming',data);
                  dispatch(getUsersData(data));
              }).catch((error)=&gt;{
                console.log('error comming',error);
                  dispatch(errorgetUsersData(error));
              });
          };
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>axios.defaults.headers.common['Authorization'] = localStorage.getItem('jwtToken');
  </code></pre>
  
  <p><strong>But When I use postman I am getting the required data from the backend</strong>. Any particular reason why I keep getting this Unauthorized error?.</p>