Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

246
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda