// file: ~/pages/get
<template>
<div>
{{ user }}
</div>
</template>
<script setup>
// fetch the user
const { data: user } = await useFetch('/api/carrier/get')
</script>
// file: ~/server/api/get.ts
import { getServerSession } from '#auth'
export default eventHandler(async (event) => {
const session = await getServerSession(event)
if (!session) {
return { status: 'unauthenticated!' }
}
return { status: 'authenticated!' }
})
Additional information
It return the session when using the nuxtlink go to the page but after refresh the page it would return null. why ?