-
|
I currently have a structure like this: Now I would like to get data from endpoint "routeA" into page from "routeB". Calling routeA's GET through fetch from routeB, but the result is not json, but the full HTML page instead, even though I am adding the following headers to fetch, like so: Any help much appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
Actually, you don't have an endpoint at routeA, endpoints are written in // routeA/page.js | page.server.js
export function load() {
return { myData }
}// routeA/page.svelte
<script>
export let data;
console.log(data.myData)
</script>// routeB/page.svelte
<script>
export let data;
console.log(data.myData)
</script> |
Beta Was this translation helpful? Give feedback.
-
|
You have a few options:
|
Beta Was this translation helpful? Give feedback.
You have a few options:
GETendpoint in+server.tswhich you canfetchfrom anywhere (likely inside+page.tsand+layout.ts).+layout.server.tsand use a(group)so both routes can inherit the data.