Skip to content
Advertisement

Calling method in my store returns empty observer object

I am new with Vue.

I have a Vue component like below. The return value of my function getBuildingsByOwnerRequest is unexpected: It returns an empty observer object. Only if I run getBuildingsByOwnerRequest again I receive the expected output from my store action.

Could this be a reactivity problem?

JavaScript

buildings.js (store):

JavaScript

Advertisement

Answer

The object is empty at the time it’s logged. All asynchronous actions should return a promise:

JavaScript

A promise needs to be awaited before accessing results that it promises:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement