Skip to content
Advertisement

Nuxt How to send async props

I’ve been having trouble with Nuxt2.15 (Vue.js). I want to send the data from parent component to child component that parent components fetched. And, I want to fetch another data from a child component by useing the data from the parent component. But props data is undefined in the child component. I tried to use “watch” and “computed” in the child component. But I couldn’t make it work. I would appreciate it if someone can show me how to fix it.

Parent

JavaScript

Child

JavaScript

Advertisement

Answer

Try to use mounted() method instead of created() like this:

JavaScript

But, if the data passed from the parent is asynchronous or could be changed at some moment, I would recommend using the watch prop like this:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement