0👍
this.row
is an empty string before the API request is done, therefore you cannot access this.row["answerq1"]
. You need to wait for the API request to finish.
Make this change and it should work:
data() {
return {
row: "",
values: {
question1: "" // set to empty string
}
};
}
- [Vuejs]-How can I bind value between parent and child component in vue?
- [Vuejs]-Leaflet error Uncaught (in promise) TypeError: layer.addEventParent is not a function
0👍
I have found the answer to my question for anyone encountering a similar problem:
new Vue({
el: '#app',
created() {
this.fetchData();
},
data: {
row: [],
values: {
question1: null
}
},
methods: {
fetchData() {
axios.get('retrieve.php')
.then((response) => {
this.row = response.data;
this.values.question1 = this.row["answerq1"];
});
},
}
})
Source:stackexchange.com