BT1010
BT1010
NNuxt
Created by BT1010 on 3/22/2024 in #❓・help
call composable from setup globally from nuxt3 layer
In my nuxt3 layer I have my own composable which is using useReCaptcha composable. (https://github.com/AurityLab/vue-recaptcha-v3) This composable must be executed from the setup therefore my own composable also needs to be executed from setup. However as this is something I always want to run when app starts on the client, I currently have it inside app.vue within the layer like this:
<script setup>
import { useCaptcha } from '@/composables/useCaptcha.ts'

if (process.client) {
const { createChallengeCookie } = useCaptcha()
createChallengeCookie()
}
</script>

<template>
<NuxtPage />
</template>
<script setup>
import { useCaptcha } from '@/composables/useCaptcha.ts'

if (process.client) {
const { createChallengeCookie } = useCaptcha()
createChallengeCookie()
}
</script>

<template>
<NuxtPage />
</template>
But this is app.vue inside a layer. I don't want to have app.vue in the layer. I want to have app.vue in the app where I use this layer. Where elsewhere I can call useCaptcha ? I want to keep execution of this composable within the layer
2 replies
NNuxt
Created by BT1010 on 7/20/2023 in #❓・help
Handling @nuxt/apollo response 400 from graph query
No description
1 replies
NNuxt
Created by BT1010 on 7/17/2023 in #❓・help
Handling Cookies in API Routes
No description
77 replies
NNuxt
Created by BT1010 on 1/19/2023 in #❓・help
useFetch & URLSearchParams nuxt3 global middlewere
Guys i'm trying out useFetch inside my global middlewere (ts file) I basically want to sent http request from the server side and use URLSearchParams as my API requires it
useFetch(`https://oauth.my-domain/oauth2/token`, {
method: "POST",
params: new URLSearchParams({
scope: "openid",
redirect_uri: "http://localhost:3000/",
grant_type: "authorization_code",
code: `${route.query.code}`
}),
body: {},
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
});
useFetch(`https://oauth.my-domain/oauth2/token`, {
method: "POST",
params: new URLSearchParams({
scope: "openid",
redirect_uri: "http://localhost:3000/",
grant_type: "authorization_code",
code: `${route.query.code}`
}),
body: {},
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
});
with this code I'm getting following error:
Error: Unknown object type "urlsearchparams" at Object._object (index.mjs?v=b79dfc53:57:17) at Object.dispatch (index.mjs?v=b79dfc53:34:30) at Object._array (index.mjs?v=b79dfc53:88:16) at Object._object (index.mjs?v=b79dfc53:53:30) at Object.dispatch (index.mjs?v=b79dfc53:34:30) at objectHash (index.mjs?v=b79dfc53:13:10) at hash (index.mjs?v=b79dfc53:481:56) at useFetch (fetch.mjs?v=b79dfc53:6:28) at default (auth.server.global.ts:23:7) at fn (nuxt.mjs?v=b79dfc53:141:27)
URLSearchParams should be available in Node so what's going on?
3 replies