could anyone pls tell me why this table isn't printing the result? it appears that axios is pulling the data ok and printing to console.log, but the view is not outputting in the table.
<table id="app">
<tbody>
<tr v-for="user in users">
<td>{{ user.id }}</td>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>{{ user.phone }}</td>
</tr>
</tbody>
</table>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.0/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
new Vue({
el: "#app",
data: {
users: []
},
methods: {
getAllUsers: function(){
axios.get("http://example.net/users/process.php?action=read").then(function(response){
if(response.data.error){
app.errorMsg = response.data.message;
}
else{
app.users = response.data.users;
console.log(app.users);
}
});
}
},
mounted(){
this.getAllUsers();
}
})
</script>
thx so much guys for your time!
appanywhere? If not thenappwill just be referring to the element with the idapp, which is not what you want. I suggest using an arrow function for thethencallback so that you can usethis.usersinstead.