title: Axios login request: Unauthorized, request status code 401
body: <p>I'm trying to get an authorization token by making a request to an api using axios:</p>
  
  <pre><code>axios({
      method: 'post',
      url: 'http://62.110.134.187/api/signin',
      headers: { 'content-type': 'application/x-www-form-urlencoded' },
      auth: {
          username: usr,
          password: pwd
      }
  }).then(function (response) {
      console.log(response)
  }).catch(function (error) {
      console.log('Error: ' + error)
  })
  </code></pre>
  
  <p>I'm getting always status code 401(Unauthorized):</p>
  
  <pre><code>Error: Request failed with status code 401
  </code></pre>
  
  <p>Where I'm doing wrong?</p>
  
  <p>The fact is that making the same request using python works fine:</p>
  
  <pre><code>payload = "username=%s&amp;password=%s" % (usr,pwd)
  headers = {'content-type': 'application/x-www-form-urlencoded'}
  response = requests.request("POST", url_login, data=payload, headers=headers)
  print(response.text)
  data = response.json()
  token = data["token"]
  </code></pre>