Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda