[Vuejs]-Vuejs: call created() hook twice

0👍

I assume that your data are reloaded from your database using projectService.getAllCompanyProjects(); function. Since you want to reload you data on “click” I suggest you to bind the “click” event to one of your component method.

<template>
  <base-projects :projects="projects" @click.native="reloadData" />
</template>

<script>
import { mapGetters } from 'vuex';
import Projects from './Projects';
import projectService from '@/services/projectService';

export default {
  components: { Projects },
  computed: {
    ...mapGetters([
      'projects'
    ])
  },
  methods: {
    reloadData() {
      projectService.getAllCompanyProjects();
    }
  }    
};
</script>

The reloadData method will be triggered by a “click” on the DOM of your base-projects component.

Leave a comment