Fix the issue where the content was not refresh when navigating between creators
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
<div v-if="creator && creator.id">
|
||||
|
||||
<creator-banner :creator="creator"></creator-banner>
|
||||
|
||||
<donation-popup :creator-id="creator.id"></donation-popup>
|
||||
|
||||
<div class="max-w-[1000px] mx-auto flex flex-row justify-center border-l-2 border-r-2 -mt-6 ">
|
||||
@@ -43,32 +44,22 @@ const route = useRoute();
|
||||
const creator = ref(null);
|
||||
const loading = ref(true);
|
||||
|
||||
onBeforeMount(async () => {
|
||||
setTimeout(() => {
|
||||
loading.value = false;
|
||||
}, 1500);
|
||||
await fetchCreatorData(route.params.creator);
|
||||
});
|
||||
onBeforeMount(async () => await fetchCreatorData(route.params.creator))
|
||||
|
||||
watch(
|
||||
() => route.params.creator,
|
||||
async () => {
|
||||
loading.value = true;
|
||||
setTimeout(() => {
|
||||
loading.value = false;
|
||||
}, 1000);
|
||||
await fetchCreatorData(route.params.creator);
|
||||
}
|
||||
);
|
||||
async () => await fetchCreatorData(route.params.creator)
|
||||
)
|
||||
|
||||
const fetchCreatorData = async (creatorAlias) => {
|
||||
try {
|
||||
loading.value = true
|
||||
const response = await client.get(`/api/creators/@${creatorAlias}`)
|
||||
creator.value = response.data;
|
||||
console.log('loaded the following creator from api');
|
||||
console.table(creator.value.id);
|
||||
creator.value = response.data
|
||||
} catch (error) {
|
||||
console.error(`Error fetching content: ${error}`);
|
||||
console.error(`Error fetching content: ${error}`)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user