I am having an issue with loading data. Just in general, I have a feeling there’s little logic (or clarity) in how the data gets loaded. I will explain the issues I’m running into and I hope someone can help me out.
I have a website where people fill out a questionnaire and after doing so end up on a results page. To get the the results page, we assign a cookie/hex code to them and we retrieve all their info based off that. I’m trying to load their Strengths and Risks. I first tried to load these server side using a plugin that checks if it needs to get populated (*.server.ts and $fetch), but I ran into some issues there and figured I don’t need the SEO benefits on that page anyway, so I’ll render it just on the client side. I renamed my component to Card.client.vue and this is where things got weird.
I have some load functions for the data that assign the data to refs.
```
const userRisks = ref<IUserRisk[]>([]);
const allStrengths = ref<IUserStrength[]>([]);
const loadStrengths = async () => {
const strengths = await useStrengths(userId);
allStrengths.value = strengths.value;
};
const loadRisks = async () => {
const strengths = await useRisks(userId);
userRisks.value = strengths.value;
};
loadStrengths();
loadRisks();
The problem I’m running into is that after the client side renders, the strengths are stored (duplicated?) into the risks variable. And the risks are not there, even though I see the risks being loaded through when I log them in the hooks. The weirdest part is that when I log the strength data, after getting it from the API, in the useStrenghts hook (see below), it logs risks. _But checking the network tab in the browser shows that there are two API calls, one to strengths and one to risks and both return the expected data_. I’ve been staring at this problem for too long and I sincerely hope someone has an idea about all this 😅