I'm struggling with iterating through this array of objects. I'm not seeing any console errors and not sure why the data is not displaying.
{
"messages":[
{
"id":1,
"sender":"frank",
"message":"Lorem ipsum...",
"time":1398894261,
"status":"read"
},
{
"id":2,
"sender":"mary",
"message":"Lorem ipsum...",
"time":1390824261,
"status":"read"
},
{
"id":3,
"sender":"john",
"message":"Lorem ipsum...",
"time":1308744200,
"status":"unread"
}
]
}
I'm using an http get request and the data is coming in, but I can't iterate through it. Here's my js:
new Vue({
el: '#app',
data: '',
ready: function() {
// GET request
this.$http.get('https://www.example.com/file.json', function (data) {
// set data on vm
this.$set('data', data.messages);
}).error(function (data, status, request) {
console.log('http request error')
})
}
})
And here's my html:
<div v-if="data">
<li v-for="d in data">{{ d.sender }}</li>
</div>
<p>{{data[0].sender}}</p> <!-- this part works -->