How do we get a .js file to use the updated Store value in Sveltekit? #4459
Unanswered
half-metal
asked this question in
Q&A
Replies: 1 comment
-
This is discussed here, but the answer seems to be that a .js endpoint cannot get the updated value from the client. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I need to update a variable in a .js file (endpoint) with a string submitted from a form on a .svelte page. Stores are straightforward in .svelte files, but I am not sure I am going down the correct path to get this value updated in the .js file. This issue is talked about on here https://stackoverflow.com/questions/59126405/is-it-possible-to-access-svelte-store-from-external-js-files but this isn't working as I expect it to and there's this video which is a bit different than what I want to do https://www.youtube.com/watch?v=oiWgqk8zG18&ab_channel=lihautan hoping someone can provide the recommended Sveltekit way to do this that is readable and straightforward to implement.
I have the following files
The first file write-query.svelte is basic which imports the queryStore and then has an input form for submitting
The queryStore.js
The query-result.js endpoint
This will return the query response but with the predefined queryValue as the query and not the updated queryValue that I submitted. What am I missing to use the submitted query in the endpoint database call? I tried using in the JS file
get(queryStore)
I tried usingqueryStore.subscribe(value =>{queryValue = value})
and the JS file still uses the original value for the query.Beta Was this translation helpful? Give feedback.
All reactions