My understanding of vue.js is limited, but based on what I know, this code should work. However, when attempting to access the variable in the data property, it seems unable to locate it.
data: function() {
return {
id: 0,
clients: []
}
},
methods: {
getClientData(){
fetch('/view-clients/' + this.id).then(function (response) {
return response.text();
}).then(function (data) {
this.clients = JSON.parse(data);
this.id = this.clients[clients.length - 1].id;
}).catch(function (error) {
console.log('Error: ' + error);
});
}
}