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

load always gets empty query parameters on the clientside #586

Closed
antony opened this issue Mar 20, 2021 · 2 comments
Closed

load always gets empty query parameters on the clientside #586

antony opened this issue Mar 20, 2021 · 2 comments

Comments

@antony
Copy link
Member

antony commented Mar 20, 2021

Describe the bug
It appears that whilst query parameters passed to a page are available to the server-side load, the client-side load always has an empty URLSearchParams object.

To Reproduce
Check out the repro project atttached. Hit any of the links on the page and examine the browser console. Now refresh any of the pages and observe the server console.

Expected behavior
I expect to see my query parameters client-side and be able to use them:

Reproduction
query-param-issue.tar.gz

Logs

Server side:

new page URLSearchParams { 'name' => 'bar' }
new page URLSearchParams { 'name' => 'baz', 'flip' => 'flop' }

Client side:

index.svelte:4 new page URLSearchParams {}
index.svelte:4 new page URLSearchParams {}

Information about your SvelteKit Installation:

  • The output of npx envinfo --system --npmPackages svelte,@sveltejs/kit --binaries --browsers
  System:
    OS: Linux 5.8 Ubuntu 20.10 (Groovy Gorilla)
    CPU: (8) x64 AMD Ryzen 7 4700U with Radeon Graphics
    Memory: 20.25 GB / 30.85 GB
    Container: Yes
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.20.1 - ~/.volta/tools/image/node/12.20.1/bin/node
    Yarn: 1.22.10 - ~/.volta/tools/image/yarn/1.22.10/bin/yarn
    npm: 7.5.2 - ~/.volta/tools/image/npm/7.5.2/bin/npm
  Browsers:
    Chrome: 89.0.4389.90
    Firefox: 86.0
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.54 
    svelte: ^3.29.0 => 3.35.0 
  • Your adapter (e.g. Node, static, Vercel, Begin, etc...)
    Static

Severity
Blocker

@Conduitry
Copy link
Member

I don't see a bug here, and I think this is just a matter of how the browser console is displaying the URLSearchParams object. If I log page.query.get('page') or page.query.toString(), I can see the appropriate query parameter in the browser.

@Conduitry
Copy link
Member

Oh, also, unlike with Sapper, page.query.name isn't what you want for the prop anymore either. You want page.query.get('name'). That's how the API works.

zhammer added a commit to zhammer/writing that referenced this issue Jun 14, 2021
zhammer added a commit to zhammer/writing that referenced this issue Jun 14, 2021
* start with some package.json work

* use svelte.config.js

* start on file changes

* directory page now loads

* getting closer

* fix mount

* get export working

* fix query params

sveltejs/kit#586 (comment)

* switch to module

* add .nvmrc

* switch plugins/index.js to ts

* more fixes, getting rid of sapper refs

* last sapper ref
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants