[Vuejs]-Call the mounted lifecycle again

4👍

You can just extract your loading logic into a method that can be called from multiple locations:

const Comp = {
  methods: {
    fetchData() {
      axios.get(....).then(response => {
        this.dataset = response.data;
      });
    },
    onSomeOtherAction() {
      // Do stuff.
      this.fetchData();
    },
  },
  mounted() { 
    this.fetchData();
  },
}

Leave a comment