1👍
since you’re destructing the response inside the callback parameters .then(({ data })
you should directly render categories
without .data
field :
<tr v-for="category in categories" :key="category.id">
- [Vuejs]-How do I save a hashmap to localstorage using Vue?
- [Vuejs]-Is there a method to update a data object from vue when the database updates?
1👍
as you sending the data from laravel using api resource the actual data is loaded inside a data property. so you should extract it like this in the axios call
loadCategory(){
axios.get("api/category").then(({ data }) => (this.categories = data.categories.data));
},
1👍
yes i just quickly want to clearify , just incase someones sees this issue both answers from @Boussadjra Brahim and @sazzad was helpfull . so what i did was
first i took @Boussadjra Brahim suggestion and changed this
<tr v-for="category in categories" :key="category.id">
<td>{{ category.id }}</td>
<td>{{ category.name }}</td>
<td>11-7-2014</td>
<td><span class="tag tag-success">Approved</span></td>
</tr>
then i still got errors until i tried @sazzad suggestion but took out the .data
attribute giving me this
loadCategory(){
axios.get("api/category").then(({ data }) => (this.categories = data.categories));
},
hope this helps someone also thanks again
- [Vuejs]-Sorting a Vuetify DataTable based on multiple fields
- [Vuejs]-Vue.js + Trigger only one event
Source:stackexchange.com