Answer the question
In order to leave comments, you need to log in
Why is the Promise object not defined?
Why is a computed property derived from a Promise throwing [object Promise] on the page itself, even though it's 14 in the console (as it should be):<div v-if="allNewsList">{{allNewsList}}</div>
const app = new Vue({
el: '#content',
computed: {
async allNewsList() {
let data = await axios.get('http://news/filtered_news/author_all/period_all').then(response => {return response.data});
console.log(data.length);
return data.length;
},
}
});
Answer the question
In order to leave comments, you need to log in
You need to wait for the result, this is an asynchronous model.this.a = await allNewsList;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question