Skip to content

Commit c598dfb

Browse files
Sync kit docs (#1549)
sync kit docs Co-authored-by: svelte-docs-bot[bot] <196124396+svelte-docs-bot[bot]@users.noreply.github.com>
1 parent bf4f09a commit c598dfb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

apps/svelte.dev/content/docs/kit/20-core-concepts/60-remote-functions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -996,13 +996,13 @@ export const getProfile = query(async () => {
996996
};
997997
});
998998

999-
// this function could be called from multiple places
1000-
function getUser() {
1001-
const { cookies, locals } = getRequestEvent();
999+
// this query could be called from multiple places, but
1000+
// the function will only run once per request
1001+
const getUser = query(() => {
1002+
const { cookies } = getRequestEvent();
10021003

1003-
locals.userPromise ??= findUser(cookies.get('session_id'));
1004-
return await locals.userPromise;
1005-
}
1004+
return await findUser(cookies.get('session_id'));
1005+
});
10061006
```
10071007
10081008
Note that some properties of `RequestEvent` are different inside remote functions. There are no `params` or `route.id`, and you cannot set headers (other than writing cookies, and then only inside `form` and `command` functions), and `url.pathname` is always `/` (since the path that’s actually being requested by the client is purely an implementation detail).

0 commit comments

Comments
 (0)