Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
Call the mounted lifecycle again

I currently have a table that uses v-for to populate the data

<table v-for="(data, idx) in dataset" :key="idx">
</table>

Then, I have two buttons that insert or delete certain things in the database after which I would like to re-populate the table to reflect these new changes.

So far, the data is captured from an API that is called in the mounted lifecycle.

mounted: function (){ 
     axios.get(....).then((response => {
           this.dataset = response.data;
     });
}

Hence, is it possible to re-call the mounted function to call the API and thus re-running the v-for?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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();
  },
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!