I have implemented a pop-up prompt that requests the user's year group. Since I have databases for each year group, I need to trigger a function once the value of userInfo
changes to true
.
My JavaScript skills are limited, and my experience has been primarily with async calls and promises related to API fetching. This is what I currently have:
Here's an example:
onMount(async function check() {
// Verify if the user has entered their information
if ($userInfo) {
getYearGroupSchedule($yeargroup, weekdates);
} else {
// Wait for userInfo to be true
}
});
I'm not sure if this is the correct approach, and I feel quite lost. Any assistance would be greatly appreciated. Feel free to ask any clarifying questions in the comments below.