0👍
Looking at your it is probably the getUser
function, which is asynchronous. Although is it not clear where this function is coming from in the code you provided. But it looks like that is returning a promise, you should await for. You can use promise chaining for that, like:
setup() {
let Profile = null;
getUser().then(data => {
const user = data.user;
const { documents } = getCollection(
'Premium',
['userId', '==', user.value.uid]
)
Profile = documents;
}).catch(err => {
console.log(err);
})
console.log(Profile)
return { Profile }
}
}
getCollection
also sounds like a function that does a call to the server and probably is async.
0👍
I had to have profile set as premium like this
<script>
import getCollection from '../Composables/getCollection';
import getUser from '../Composables/getUser';
import getPremium from "../Composables/getPremium.js";
const {Premium, error, load} = getPremium();
load();
export default{
setup() {
const { user } = getUser()
const { documents: Premium } = getCollection(
'Premium',
['userId', '==', user.value.uid]
)
console.log(Premium)
return { Premium }
}
}
</script>
<template>
<br><br>
<div v-if="error">{{ error }}</div>
<div v-if="Premium" class="Profile">
<p class="text-5xl text-red-700 font-serif">Your Profile Statistics</p>
<div v-for =" Premium in Premium" :key="Premium.id">
<p class="text-5xl text-red-700 font-serif">Your Profile Statistics</p>
<p class="text-5xl text-red-700 font-serif">{{ Premium.name }}</p>
<br><br>
</template>
Once I did this it was fixed.
- [Vuejs]-Assign Fetch output to another variable in VueJS 3 / Composition API
- [Vuejs]-Unable to store data in vuex "State"
Source:stackexchange.com