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.

Wrong query serialialization of defaultParams

See original GitHub issue

Hey, thanks for a great lib, I found that query serialization is broken at least with defaultParams if empty arrays are presented. here is the object I use:

defaultParams: {
        a: 'string',
        b: [],
        c: [],
        d: [1, 2],
      }

and I’m getting following query ?a=string&&&d=1&d=2 as you might see there is additional & symbols for removed empty params. It getting worse after reload, because in this case route cant parse this query string correctly.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Reaverartcommented, Aug 11, 2017

Just a thought about tricky moment here, without brackets we cant be sure when foo=bar is a { foo: bar } or if it a { foo: ['bar'] }, so maybe we need a configuration option? to serialize arrays in more explicit way, foo[]=bar or foo[0]=bar? hmm, a link to consider https://github.com/sindresorhus/query-string#arrayformat-1

0reactions
Reaverartcommented, Sep 5, 2017

Hi, @troch I was thinking about this issue, the way you mention in last comment isnt really suitable for me because params might change. But what if route config will accept custom parse / serialize (encode / decode) function? Then we will have flexible way to control query params on our own, anyone will be able to take any 3rd party lib he like for parsing/serialization queries or wrtite something specific when needed. Or maybe there is middleware for that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default params serialisation behaviour incompatible ... - GitHub
Summary Given the default params serialisation behaviour, axios out-of-the-box may fail to work with recent Tomcat versions out-of-the-box.
Read more >
Android retrofit jackson wrong query parameter serialization if ...
For example, I have an enum object FruitEnum.FRUIT : enum class FruitEnum { @JsonProperty("fruit") FRUIT }. which I want to pass as query...
Read more >
Parameter Serialization - Swagger
Possible styles depend on the parameter location – path, query, header or cookie. ... The default serialization method is style: simple and explode:...
Read more >
Serialization
To use Query & Analysis other than in Demonstration Mode, you must enter your serialization details for all installed Query & Analysis products...
Read more >
serialize-query-params - npm
A library for simplifying encoding and decoding URL query parameters.. Latest version: 2.0.2, last published: 2 months ago.
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