-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query string hook #159
Comments
sounds like a dup of #72, we don't want to bloat moreover, mapping key/values for uri encoding looks different than JSON so I wouldnt want to say stringify |
@reqshark , although it's similar to #72, I don't think this is a duplicate. Here I am pointing out that using the
I understand. This is intended to be the most lightweight approach to handling query strings in an agnostic, declarative way. It'd only be a few lines of code added to this lib.
Alright, that's fine. We could use whatever want for the API name. It doesn't have to be My argument is that the very teeny increase in filesize is worth the benefits. Namely:
|
I'm afraid people would find examples of it online and miss the fact that they need to provide an implementation though, so we'd have to throw a descriptive error if that happens. |
That makes sense to me. @naugtur, if you'd like me to whip up a PR to get a sense of what this would look like, let me know and I can put it together. I don't think it'd be too much work, so if it doesn't get merged, then that's fine. I'll be sure to add in an error. Speaking of throwing an Error, I'll cross-reference #58 , since that conversation is relevant to this issue. |
@jmeas Sure, just to see what the API could be, we can then iterate and see if we come up with something that's not going to confuse anyone. |
@reqshark just an FYI, Edit: Whoops referenced the wrong dev in the comment, since updated, sorry about that @naugtur |
Resolved in #160 to be released in v3. Closing. |
I love this library and its commitment to simplicity. I always reach for it on new projects. One thing I always need to add in is query string support. I'm glad this lib doesn't include this out of the box, because there are so many ways to stringify query string objects.
Myself, and many devs I work with, aren't satisfied with a system where the query string is built and then appended to the URI before passing it into xhr. In other words, this API:
A declarative approach would be more preferable. However, it's not trivial to wrap
xhr
to add in support for aqs
option due to the numerous argument signatures it accepts. It's not impossible, by any means, but this is what I currently do:A simpler alternative would be a hook within this library that would work like follows:
qs
option will be passed to it. The return value of the hook is appended to the URI.The example code I wrote at the start of this issue would then become:
I'd be happy to whip up a PR if there's interest. Otherwise, I understand the desire to keep this lib slim. No worries, either way!
Thanks for reading!
The text was updated successfully, but these errors were encountered: