You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Help me understand the way to update the $page store
Hello everyone. In my SvelteKit App I fetch the ipgeolocation data of the user on first load but then I try to update it; the logs show that the new data is fetch but the $page.data is not updated.
Here is the load function of the page:
// src/routes/+page.tsimporttype{PageLoad}from"./$types";import{error}from"@sveltejs/kit";import{api,getErrorMessage}from"$lib/utils";exportconstprerender=false;exportconstload: PageLoad=async({ fetch, url })=>{constparams=url.searchParams.get("ip")??undefined;try{constresponse=await(awaitfetch(api.createEndpoint(params),{method: "GET"})).json();if(response.message)thrownewError(response.message);constsearchResults=api.formatApiResponse(response);/** This log shows both in the server & in the browser on first load but only in the server after that **/console.log(searchResults);return{ searchResults };// Never updates the pageData}catch(err){throwerror(500,getErrorMessage(err));}};
Here is the fetch call i do on the client to update the data:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Help me understand the way to update the $page store
Hello everyone. In my SvelteKit App I fetch the ipgeolocation data of the user on first load but then I try to update it; the logs show that the new data is fetch but the $page.data is not updated.
Here is the load function of the page:
Here is the fetch call i do on the client to update the data:
Could you help me understand what i am doing wrong I am stuck right now. Peace 😊
Beta Was this translation helpful? Give feedback.
All reactions