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

Support boolean options in searchParams? #182

Closed
achingbrain opened this issue Oct 4, 2019 · 2 comments · Fixed by #188
Closed

Support boolean options in searchParams? #182

achingbrain opened this issue Oct 4, 2019 · 2 comments · Fixed by #188
Assignees
Labels
enhancement New feature or request

Comments

@achingbrain
Copy link

The following code causes ky to throw an error:

const res = await ky.post('some/path', {
  searchParams: {
    'some-param': true
  }
})
Error: The `searchParams` option must be either a string, `URLSearchParams` instance or an object with string and number values
      at new Ky (node_modules/ky/umd.js:272:13)
      at Function.ky.(anonymous function) [as post] (node_modules/ky/umd.js:501:37)
      ...

Is there any reason why boolean values are not supported in the searchParams option?

If you create a URLSearchParams instance, add the boolean values to that and pass it in as the value of searchParams it works as expected, though it's just extra boilerplate.

@sholladay
Copy link
Collaborator

Yes that is a strange limitation.

I'll try to fix this as soon as PR #180 lands. So, tentatively, it'll most likely be in Ky v0.16.

@sholladay sholladay added the enhancement New feature or request label Oct 6, 2019
@sholladay sholladay self-assigned this Oct 29, 2019
@sholladay
Copy link
Collaborator

Working on this now. Very cool to see Ky being used in an IPFS project! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants