From 3ead228fb90f499ce6a89a9b6264c0d6d75abaef Mon Sep 17 00:00:00 2001 From: Valentyne Stigloher Date: Sun, 23 Feb 2025 12:40:35 +0100 Subject: [PATCH] (nuxt) call /api/admin/moderation only when permissions are detected to prevent 401 response (not user-visible) --- components/ModerationRules.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/ModerationRules.vue b/components/ModerationRules.vue index 33a36e620..29786fdc2 100644 --- a/components/ModerationRules.vue +++ b/components/ModerationRules.vue @@ -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], +});