sveltejs / realworld

SvelteKit implementation of the RealWorld app
https://realworld.svelte.dev
MIT License
2.24k stars 353 forks source link

Prop being define as "undefined" #104

Closed PhoenixDevStudio closed 2 years ago

PhoenixDevStudio commented 2 years ago

I am trying to build a movie app, I am exporting popular as a prop to a component but every time I run the console is saying popular is undefined what am I doing wrong? This is my code;

<script context="module"> 
 export async function popularLoad({fetch}) {
 const res = await fetch(`https://api.themoviedb.org/3/movie/popular?api_key=b2b2c2d249db772c4fec3e4b4ce753e1&language=en-US&page=1`);
 const data = await res.json();
 if (res.ok) {
 return {
 props: { popular: data.results }
        };
    }
}
</script>

<script>
 import PopularMovies from "../components/PopularMovies.svelte";
 export let popular;
</script>

<section>
  <PopularMovies {popular}/>
</section>
benmccann commented 2 years ago

This is a better question for Diacord

PhoenixDevStudio commented 2 years ago

This is a better question for Diacord

Who is Diacord?

benmccann commented 2 years ago

Typo. I meant Discord