<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!!!
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));
},
.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));