Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1662

Svelte 5 how to fetch data from an API?

$
0
0

I am not sure how to fetch data in SvelteKit 5. In the below data is a Proxy object

<script>export async function load({ fetch }) {    const res = await fetch('https://renovatorsparadisewebsite.kinsta.cloud/wp-json/rp2024/v1/top-menu');    const data = await res.json();    return {      props: { data }    };  }  const { data } = $props();  console.log(data);</script>

enter image description here

I tried changing the variable name data


Viewing all articles
Browse latest Browse all 1662

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>