My (vuejs) homepage contains the following:
template:
<h3>{{ strings.home_headline }}</h3>
scripts:
data() {
return {
strings: []
};
},
methods: {
fetchData: function(){
var self = this;
// get translatable strings
axios
.get(MY_API_URL, {
headers: { "X-Locale": self.locale }
})
.then(function(data) {
self.strings = data.data;
// This console works and outputs the right content;
console.log("strings: ", self.strings);
// outputs the text that should come in the H3
console.log(strings.home_headline)
})
.catch(function(error) {
console.log("Error", error);
});
}
},
created() {
this.fetchData();
}
the console.log works but the template h3 is empty, UNTIL the first pixels scrolled, then everything is filled in with the text. what am i doing wrong here?
console.loglogs)stringsas an object, not an array:strings: {}