0
axios.defaults.headers.common['Authorization'] = "Bearer "+localStorage.getItem('token'); 
              axios.get(baseUrl+'/country/fetch/'+id)
              .then((response) => {



                })
                .catch(function (error) {
                console.log(error);
            });

Please help me to pass data from child to parent. Here I am getting data as response. Now I want to pass this to parent How can I?

Kevin
  • 653
  • 2
  • 13
  • 34
  • 1
    Possible duplicate of [Update parent model from child component Vue](https://stackoverflow.com/questions/41663010/update-parent-model-from-child-component-vue) – Jns Nov 14 '18 at 12:47

1 Answers1

0

Vue has a simple approach for that.

From parent to child: Use Props

From child to parent: Use Events

That means your childComponent should call in the then part:

this.$emit('newData', response)

And your parentComponent should listen to it with:

Markup

<childComponent @newData="handleNewData"/>

ComponentCode

methods: {
    handleNewData(data) {
        console.log(data)
    }
}
Thomas
  • 2,431
  • 17
  • 22