question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Content-Type application/x-www-form-urlencoded

See original GitHub issue

Try to send request with content type application/x-www-form-urlencoded

var data = Querystring.stringify({ 
                "grant_type": "password",
                "username": login,
                "password": password
            });
axios.post(Urls.login, data);

but there is no such header in request.

I tried to use code:

  var data = Querystring.stringify({ 
                "grant_type": "password",
                "username": login,
                "password": password
            });
        return axios({
            method: 'post',
            url: Urls.login,
            data: data,
            headers: {
                'Content-type': 'application/x-www-form-urlencoded'
            }
        });

same problem

jquery code works fine:

$.ajax({
            url: Urls.login,
            data: data,
            type: "POST",
            headers: {
                'Content-type': 'application/x-www-form-urlencoded'
            }
        });

How can I use axios to send request with this header?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:101
  • Comments:220 (5 by maintainers)

github_iconTop GitHub Comments

179reactions
nickuraltsevcommented, Jul 25, 2016

You can use a library like qs instead:

var qs = require('qs');
axios.post('/foo', qs.stringify({ 'bar': 123 });
76reactions
brickgalecommented, Dec 8, 2016

+1 for issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

application/x-www-form-urlencoded or multipart/form-data?
The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters.
Read more >
POST - HTTP - MDN Web Docs
The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header....
Read more >
'x-www-form-urlencoded' or 'form-data' ? Explained in 2 mins.
Send a request with form-data. Content Type. content-type. x-www-form-urlencoded, application/x- ...
Read more >
Content Type : x-www-form-urlencoded, form-data and json
Basically there are three ways to send the HTML data to the server. “Content Type : x-www-form-urlencoded, form-data and json” is published ...
Read more >
Difference Between form-data, x-www-form-urlencoded and ...
The URL-encoded data sends encoded data to the server, and uses the same encoding as that of the URL parameters. To use it,...
Read more >

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found