O
O
ObehanProger2019-08-15 10:38:33
JavaScript
ObehanProger, 2019-08-15 10:38:33

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

2 answer(s)
I
Ihor Bratukh, 2019-08-15
@BRAGA96

You need to wait for the result, this is an asynchronous model.
this.a = await allNewsList;

N
nvdfxx, 2019-08-15
@nvdfxx

And what for to you here basically the calculated property?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question