How can I pass data written to a store on +page.svelte to a +page.server.ts #11923
Replies: 1 comment
-
Since you have the user's preference as a form of client-side session information in the store, when requesting the URL two pages down that needs that information, you could pass the information through URL parameters or bake it into the URL path using slugs (eg. I'm not sure how you have structured navigation, but if this date and city data is common across a series of pages, you could consider placing these pages within the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi and TIA.
Ive been searching and struggling with this issue for weeks now.
I have a landing page which requests location permission, and then the user selects a date from a simple date picker and this is written to a store.
I want to be able to use this data 2 pages later when i return the results of a ML calculation. the data is a a simple city and date that I need to add to my SQL query to be performed before the ML.
Can anyone help me with this please?
FWIW I dont need to use a store, if you have other suggestions.
My +page.server.ts already has a load function which is doing many other things such as calling the DB and processing the data and its currently set up like this
export const load: PageServerLoad = async () => {
`"devDependencies": {
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-auto": "^1.0.0",
"@sveltejs/adapter-node": "^1.1.3",
"@sveltejs/kit": "^1.0.0",
"@types/google.maps": "^3.55.1",
"@types/pg": "^8.11.0",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"autoprefixer": "^10.4.13",
"date-picker-svelte": "^2.10.1",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte3": "^4.0.0",
"postcss": "^8.4.20",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1",
"svelte": "^3.54.0",
"svelte-check": "^2.9.2",
"svelte-kit-env": "^1.0.0",
"tailwindcss": "^3.2.4",
"tslib": "^2.4.1",
"typescript": "^5.3.3",
"vite": "^4.0.0",
"vitest": "^0.25.3"
Beta Was this translation helpful? Give feedback.
All reactions