I'm using Laravel and Vue connected via API, Everything works fine. I asked to get offer via method from Vue:
getOffer(id) {
this.$http.get('http://127.0.0.1:8000/api/offers/'+id)
.then(response => response.json())
.then(result => this.offer = result)
}
},
And I recived this:
{
"body": "xx"
"title": "yy"
}
and then put it into offer variable:
data() {
return {
offer: {
title:'',
body:''
}
}
},
and I used it into template
<div>
<h3 class="headline mb-0">{{offer.title}}</h3>
<div>
<br>
{{offer.body}}</div>
</div>
easy, all works fine
Now I decided to use Laravel Resource. This is wrapping data into "data" object within json response, so I got now this:
{
"data": {
"body": "xx"
"title": "yy"
}
}
and my template is blank - can anyone tell me how should I change the code, to work with new data object? And how I could work with it, when It will contain more objects, like:
{
"data": {
"body": "xx"
"title": "yy"
},
"data2":{
"body": "xx"
"title": "yy"
},
}
etc.