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

245
Views
How to get data in mounted from axios call
<ion-row class="cards-wrapper">
  <theme-card
    v-for="theme in filteredThemes"
    :router-link="`/theme/${theme.slug}`"
    :key="theme.id"
    :name="theme.name"
    :tags="theme.tags"
    :id="theme.id"
    :path="theme.image.path"
  ></theme-card>
</ion-row>


mounted() {
  this.getThemes();
  this.filteredThemes = this.themes;
  console.log(this.themes);
},


//in methods:

async getThemes() {
  await axios
    .get("url")
    .then((response) => (this.themes = response.data));
},

I tried using async/await but its not working right (probably I'm using it wrong), when I console log themes in mounted I don't get my data, I'd like to get data from my api call in mounted. I know this has something with asynchronicity, can u give me a hint what to do? Thank you very much!!!

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

0

If you still don't get data, try like this:

async mounted() {
  await this.getThemes();
  this.filteredThemes = this.themes;
},

//in methods:

async getThemes() {
  await axios
    .get("url")
    .then((response) => (this.themes = response.data));
},
about 4 years ago · Juan Pablo Isaza Report

0

.then((response) => (this.themes = response.data));

using an arrow function changes what this is, i've seem some people writing it like:

const that = this;

await axios
  .get("url")
  .then((response) => (that.themes = response.data));
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!