(nuxt) call /api/admin/moderation only when permissions are detected to prevent 401 response (not user-visible)

This commit is contained in:
Valentyne Stigloher 2025-02-23 12:40:35 +01:00
parent aba7e48315
commit 3ead228fb9

View File

@ -10,7 +10,14 @@ const props = withDefaults(defineProps<{
label: 'Moderation rules',
});
const { data: moderation } = await useFetch('/api/admin/moderation', { server: false, lazy: true, pick: [props.type] });
const { $isGranted: isGranted } = useNuxtApp();
const { data: moderation } = await useFetch('/api/admin/moderation', {
immediate: isGranted('panel'),
server: false,
lazy: true,
pick: [props.type],
});
</script>
<template>