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.

Docs confusion: issue with using querystring with axios

See original GitHub issue

In docs for axios I see this:

In node.js, you can use the querystring module as follows:

var querystring = require(‘querystring’); axios.post(‘http://something.com/’, querystring.stringify({ foo: ‘bar’ }));

I tried this and it didn’t work for me. Later I found this ticket which still open: https://github.com/axios/axios/issues/362

And I think I know why it’s still open…

“querystring.stringify” works different from “qs.stringify”. See this ticket: https://github.com/nodejs/node-v0.x-archive/issues/1665

See:

first querystring:

$ node -e "console.log(require('querystring').stringify({a:{b: 1, c: 2}}));" $ a=

then qs:

$ node -e "console.log(require('qs').stringify({a:{b: 1, c: 2}}));" $ a%5Bb%5D=1&a%5Bc%5D=2

querystring doesn’t support nested objects.

What I suggest:

  1. Make a note in axios documentation to explicitly let people know that “querystring.stringify” doesn’t stringify nested objects.
  2. After that I think you can close this ticket: https://github.com/axios/axios/issues/362

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
airs0urcecommented, Nov 27, 2018

@wasnlosdu Sure. Will do it

0reactions
airs0urcecommented, Nov 27, 2018

Done

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to correctly use axios params with arrays - Stack Overflow
I got using "paramSerializer" a bit confuse. Before looking for the "right way" to use axios with array querystring on Google, ...
Read more >
axios cookies not set | The AI Search Engine You Control
XMLHttpRequest from a different domain cannot set cookie values for their own domain unless withCredentials is set to true before making the request....
Read more >
Understanding Axios GET requests - LogRocket Blog
Learn how to make GET requests in Axios with query parameters and API keys, ... protocol for fetching resources such as HTML documents....
Read more >
How do you send query parameters in an Axios POST request?
Don't confuse the query string with data queries (yes, the word 'query' can be confusing here). If you are looking for running data...
Read more >
Common data fetching patterns for real apps with react-query
Fetch a subset of data using query strings or query params: useQuery ... Axios and react-query both return responses wrapped in an envelope ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

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

No results found

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