Skip to content
Advertisement

Vuejs display result after completion of async request

I am displaying the name of the current user after querying it from the firestore database like so:

JavaScript

then after fetching the result it should be something like below:

enter image description here

However it does not display the name after the result is fetched immediately,since it takes some time. I am only able to show it after I change some property such as the margin.

How can I display it immediately the result is caught.

My template code:

JavaScript

Advertisement

Answer

Assign new object reference in the this.currentUserDetails for reactivity.

JavaScript

Alternate: you can use this.$set() to get the reactivity working:

JavaScript

Vue.js Docs

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