TheDreWen
TheDreWen
NNuxt
Created by TheDreWen on 11/6/2024 in #❓・help
How do I pass a variable from the middleware to my page?
import { api_url } from "~/src/variables";

export default defineNuxtRouteMiddleware(async (to, from) => {
const {data, error} = await useFetch<{ connected: boolean, user: {email: string, root: boolean, username: string, user_id: number} }>(api_url+"check-session");
if(!data.value?.connected){
return navigateTo("/");
}else{
// Pass variable
}
});
import { api_url } from "~/src/variables";

export default defineNuxtRouteMiddleware(async (to, from) => {
const {data, error} = await useFetch<{ connected: boolean, user: {email: string, root: boolean, username: string, user_id: number} }>(api_url+"check-session");
if(!data.value?.connected){
return navigateTo("/");
}else{
// Pass variable
}
});
44 replies