-
-
Notifications
You must be signed in to change notification settings - Fork 432
how do i get access to my route parameter #648
Comments
Documentation for the latest Sapper updates is still a work in progress. You can follow along with it's progress in #638 . To get access to the page store, which contains the objects you want, try: <script>
import { page } from '@sapper/app';
$: console.log($page);
</script>
<p>Page URL queries:</p>
<pre>{JSON.stringify($page.query, null, 2)}</pre> Also, the docs about how stores work is over at https://svelte.dev/docs#svelte_store |
Also worth noting this might be changing with #642 |
This has changed in 0.26.0 final, and is described here |
I wish the docs explained it better. I'm doing this:
All the values are undefined. I am trying to get to the value in the url after the |
@jcollum
|
Thanks. I sorted it out and put up a gist: https://gist.github.com/jcollum/29211cf188c4174d75e2cf1a90b2cb68 Line 11 and 19 are the key lines there |
Following @jcollum gist, this worked for me:
Versions: |
It seems this is made a bit too complex, I wish there was a magic thingy that would make <script context="module">
export async function preload(page) {
return {uid: page.params.myparam};
}
</script>
<script>
export let myparam;
</script> |
Given this folder structure |
In your case, you should make sure to use e.g. |
I am using v3 and it complains if i do default export.
it says query and params doesn't exist so i can't just use them undeclared.
How do i get access to this.
The text was updated successfully, but these errors were encountered: