Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On the basic KV-pair structure of a query:
qs
is indeed made redundant byURLSearchParams
. But,qs
supports a superset of the URL Query Syntax that supports deeply nested data, and acts differently is certain conditions.The reason a more complicated format become useful in situations where you need to transmit non-path data in HTTP methods like GET. For instance, applications like Strapi strictly adhere to the HTTP method definition but needs additional information for functions like nested data population.
In this changeset, I've removed the whole recommendation, but I accept that another change would be to recommend only using
qs
if you need the superset support.Examples
Stringifying
* I've URI decoded the strings for clarity
Parsing
Aside about
URL
Tangential FYI:
URLSearchParams
is fine for most applications, butURL
is finicky. Depending on environment (Node vs Browser), it may or may-not parse the string as a URL or URL-like. For instance:mongodb://...
URL will not be treated as a URL in the browser, but will in Node.A demonstraction is available here.
chrome:...
ends up getting special treatment and will get treated as if it is a URL, while being out of spec.Most of the time people use HTTP(S) URLs and will never face this problem, but sometimes this can require avoiding the built-in.