Skip to content
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

Convenience method for serializing URLSearchParams #142

Closed
timruffles opened this issue Aug 12, 2016 · 5 comments
Closed

Convenience method for serializing URLSearchParams #142

timruffles opened this issue Aug 12, 2016 · 5 comments
Labels
needs implementer interest Moving the issue forward requires implementers to express interest topic: api

Comments

@timruffles
Copy link

timruffles commented Aug 12, 2016

It'd be great to have a simple static method to go from key-value data to a formatted string in a single step:

// using typescript to reveal types

// the idiomatic way to express kv data in JS
type dict = { [key: string]: string };

class URLSearchParams {
  static toQueryString(params: URLSearchParams | dict): string;
}

This'd allow for idiomatic composition with other core JS APIs, making for a pleasant developer experience:

// creating
const queries = [{ k1: "v1"}, { k1: "v2" }]
const results = queries
  .map(URLSearchParams.toQueryString)
  // [ 'k1=v1&k1=v2' ]
  .map(qs => fetch(someUrl + "?" + qs))
@timruffles timruffles changed the title Convenience method for serializing Convenience method for serializing URLSearchParams Aug 17, 2016
@timruffles
Copy link
Author

Prior art: NodeJS

@annevk
Copy link
Member

annevk commented Dec 19, 2016

Isn't this just obj.toString()?

@annevk
Copy link
Member

annevk commented Dec 19, 2016

Apologies for the late reply by the way.

@timruffles
Copy link
Author

timruffles commented Dec 19, 2016 via email

@annevk annevk added needs implementer interest Moving the issue forward requires implementers to express interest topic: api labels Dec 19, 2016
@annevk
Copy link
Member

annevk commented May 4, 2020

Since there haven't been a lot of requests for this I'm going to close this. If someone can demonstrate this is a popular thing for libraries to add and a popular question on StackOverflow I'm happy to reconsider.

@annevk annevk closed this as completed May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs implementer interest Moving the issue forward requires implementers to express interest topic: api
Development

No branches or pull requests

2 participants