I\'ve created a page where I want to get all my data from the database with an API call, but I\'m kinda new to VueJS and Javascript aswell and I don\'t know where I\'m getti
As mentioned by Husam Ibrahim, you should wait the async fetch() function to resolve. Another approach could be use async/await in your function:
methods: {
async fetchPigeons(){
await fetch('api/racingloft')
.then(res => res.json())
.then(res => {
console.log(res.data);
this.pigeons = res.data;
})
}
}
And then it should work:
Pigeons in the racing loft
{{ pigeon.id }}