Alireza
Alireza
NNuxt
Created by Pawieplays on 3/12/2024 in #❓・help
fetch failed
Look like you are using nuxt-auth module
6 replies
NNuxt
Created by Pawieplays on 3/12/2024 in #❓・help
fetch failed
Can you provide more context?
6 replies
NNuxt
Created by Alireza on 7/2/2023 in #❓・help
Is it possible to select/define which server middlewares should be run on a specific server route?
Thanks @Cake
5 replies
NNuxt
Created by Alireza on 7/2/2023 in #❓・help
Is it possible to select/define which server middlewares should be run on a specific server route?
Would something like this work?
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",
});
}
}
})
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",
});
}
}
})
5 replies
NNuxt
Created by AngeloK on 6/1/2023 in #❓・help
Optimistic UI with useAsyncData?
onRequest etc are called interceptors. The come from the ofetch package which is same as the $fetch It should be possible to do it like this in theory
const { data, pending, error, refresh } = await useAsyncData(
'mountains',
() => $fetch('https://api.nuxtjs.dev/mountains', {
async onRequest({ request, options }) {...}
})
)
const { data, pending, error, refresh } = await useAsyncData(
'mountains',
() => $fetch('https://api.nuxtjs.dev/mountains', {
async onRequest({ request, options }) {...}
})
)
2 replies
NNuxt
Created by Alireza on 2/16/2023 in #❓・help
Recommended place to put custom types
Just to make sure, there is no auto-import for types yet? right?
6 replies