Skip to content
Discussion options

You must be logged in to vote

You have a few options:

  1. Create a GET endpoint in +server.ts which you can fetch from anywhere (likely inside +page.ts and +layout.ts).
-someResource
|-- +server.ts // GET endpoint here
-routeA
|-- +layout.ts // fetch /someResource
|-- +layout.svelte
|-- +page.svelte
-routeB
|-- +page.ts // fetch /someResource
|-- +page.svelte
  1. Retrieve your data in a load function inside +layout.server.ts and use a (group) so both routes can inherit the data.
-(yourGroup)/
|-- -routeA/
|-- |-- +layout.svelte
|-- |-- +page.svelte // receive data prop
|-- -routeB/
|-- |-- +page.svelte  // receive data prop
|-- +layout.server.ts // load function returns data
|-- +layout.svelte 
  1. Abstract the retrieval o…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@xpluscal
Comment options

Comment options

You must be logged in to vote
3 replies
@xpluscal
Comment options

@eltigerchino
Comment options

@xpluscal
Comment options

Answer selected by xpluscal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants