I'd like to have a data prop populated by data received from an axios http request. Here's a simplified version of the issue.
I would like the 'hello' prop to populate when the app loads. And when the user clicks the button, the 'hello' prop should update. The click-and-update part is working as expected, but how do I get the data to populate the 'hello' prop initially? I've also tried it with computed properties, but that also doesn't populate the 'hello' prop on the initial load. Thanks!
<div id="app">
<h1>{{ hello }}</h1>
<button @click="updateText()">Update text!</button>
</div>
var app = new Vue({
el:'#app',
created() {
updateText() // Calling this here does not work
},
data: {
hello: ''
},
methods: {
updateText: function() {
this.hello = 'hello'
}
}
});