nuxt-auth
export default defineEventHandler( async (event) => { const url = getRequestURL(event); if (url.pathname.startsWith("/api/user") ){ const user = getUser() if (!user) { throw createError({ statusCode: 401, statusMessage: "unauthorized", }); } }})
onRequest
ofetch
$fetch
const { data, pending, error, refresh } = await useAsyncData( 'mountains', () => $fetch('https://api.nuxtjs.dev/mountains', { async onRequest({ request, options }) {...} }))