I'm having trouble fetching data from the moviedb using Svelte.
That's how I try to import the data.
<script context="module">
export async function load({fetch}) {
const res = await fetch(
`https://api.themoviedb.org/3/movie/popular?api_key=<API_KEY>&language=en-US&page=1`
);
const data = await res.json();
if(res.ok) {
return {
props: { popular: data.results }
};
}
}
</script>
<script>
export let popular;
console.log(popular);
</script>
The Commandline was giving me errors that popular is undefined, I have no clue why and I have tried different methods of fetching the data and assigning the variable, but none worked the way is should have.