title: Axios returns promise pending
body: <p>i want this function to return either true or false, instead I get  </p>
  
  <pre><code>/**
   * Sends request to the backend to check if jwt is valid
   * @returns {boolean} 
   */
  const isAuthenticated = () =&gt; {
      const token = localStorage.getItem('jwt'); 
      if(!token) return false; 
      const config = {headers : {'x-auth-token' : token}}; 
  
      const response = axios.get('http://localhost:8000/user' , config)
      .then(res =&gt;  res.status === 200 ? true : false)
      .catch(err =&gt; false);
  
      return  response;
  }   
  
  export default isAuthenticated; 
  </code></pre>
  
  <p>I tried separating  them and using async/await : </p>
  
  <pre><code>const isAuthenticated = async () =&gt; {
      const response = await makeRequest();
      return  response;
  }   
  
  
  const makeRequest = async () =&gt; { 
      const token = localStorage.getItem('jwt'); 
      const config = {headers : {'x-auth-token' : token}}; 
      const response = await axios.get('http://localhost:8000/user' , config)
      .then(res =&gt;  res.status === 200 ? true : false)
      .catch(err =&gt; false);
  
      return response;
  }
  </code></pre>
  
  <p>And still the same..</p>
  
  <p>After some suggestions : </p>
  
  <pre><code>const isAuthenticated =  () =&gt; {
      const response =  makeRequest();
      return  response;
  }   
  
  
  const makeRequest = async () =&gt; { 
      try {
          const token = localStorage.getItem('jwt'); 
          const config = {headers : {'x-auth-token' : token}}; 
          const response = await axios.get('http://localhost:8000/user', config);
          if (response.status === 200) { // response - object, eg { status: 200, message: 'OK' }
              console.log('success stuff');
              return true;
          }
          return false;
     } catch (err) {
          console.error(err)
          return false;
     }
  }
  export default isAuthenticated; 
  </code></pre>