You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! Thanks for making this package, I'm finding it much more robust than the custom querystring constructor I wrote myself.
Here's my question: is there a way to rename a key while encoding its value? I'm wrestling with an API that expects the consumer to potentially provide limit?: number and limit?: { // ... } on some object, potentially at the same time. It's weird and frustrating, since I can't have two members with the same key on the query object. However, when expressed in the querystring limit=20&limit[apps]=30, it's technically valid. One way I'm getting around this is to name the object-typed limit key limitField to maintain symmetry with other parts of the query. In my custom stringify-er, I renamed the limitField key back to limit manually. Is it possible with the feature set that qs has today to perform that rename during processing?
The text was updated successfully, but these errors were encountered:
I have no concept of how limit=20&limit[apps]=30 makes any sense given that rails, php, and express will likely be unable to parse that into an object structure properly.
It certainly seems reasonable to provide (in both parse and stringify), a kind of mapKey option, that takes a key and its value and returns a mapped key name. Would that suffice? I'm thinking you could provide something like mapKey: (key, value) => key !== 'limitField' ? key : 'limit'.
This might be complex to implement, however, so unless someone submits a PR it might not happen quickly.
Hey! Thanks for making this package, I'm finding it much more robust than the custom querystring constructor I wrote myself.
Here's my question: is there a way to rename a key while encoding its value? I'm wrestling with an API that expects the consumer to potentially provide
limit?: number
andlimit?: { // ... }
on some object, potentially at the same time. It's weird and frustrating, since I can't have two members with the same key on the query object. However, when expressed in the querystringlimit=20&limit[apps]=30
, it's technically valid. One way I'm getting around this is to name the object-typedlimit
keylimitField
to maintain symmetry with other parts of the query. In my custom stringify-er, I renamed thelimitField
key back tolimit
manually. Is it possible with the feature set that qs has today to perform that rename during processing?The text was updated successfully, but these errors were encountered: