I'm fairly new to Vue and am having a tough time grasping all of the concepts. I am currently building a Laravel application and am using Vue to supplement some views. What I am trying to do is a pretty simple call to my backend API with the help of a prop set up with the Vue component (Laravel Nova card).
I have an account_id
that I am able to access through a prop like so:
resource.fields[3].value
I am then trying to make a call to the api and save data relevant to the account
data() {
return {
account: {
name: '',
location: '',
type: ''
}
};
},
methods: {
getAccount() {
let vm = this;
var account_id = vm.resource.fields[3].value;
page_url = page_url || '/api/accounts/${account_id}';
fetch(page_url)
.then(res => res.json())
.then(res => {
this.account = res.data;
})
.catch(err => console.log(err));
}
}
And then render it in my view:
<h1>{{ account.name }}</h1>
<p>{{ account.location }}</p>
<p>{{ account.type }}</p>
All of my endpoints are correct - when I visit app.dev/api/accounts/{id}
I get a JSON array with all of my fields. But, I see no data in my views when I try to render it.
How can I accomplish this?