This is my current component setup:
<template>
<Grid :items="items" />
</template>
<script setup>
import { ref, onMounted } from 'vue'
import Grid from '@/components/Grid.vue'
import { getData } from '@/services/getData'
const items = ref()
onMounted(async () => {
items.value = await getData()
})
</script>
The Grid
component depends on the items
property to display data. However, I encounter a warning stating
type check failed for prop "items". Expected Object, got Undefined
. This occurs because items
is undefined before getData()
is called. How can I ensure that getData()
is executed before this error is triggered?