You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
Having a page where I need to get user's session/cookie data from the server/backend:
Firstly, on SSR, there is no Cookie on useNuxtApp().ssrContext.req.headers! (This would have sufficed for my use case)
secondly, I tried a workaround option like this
// server/api/student/reqisterimporttype{IncomingMessage,ServerResponse}from'http'import{setCookie}from'h3export default async (req: IncomingMessage, res: ServerResponse) => { const body = await useBody(req) // do a db operation that returns an object containing registered student const { registeredStudent } = await AddStudent(body) setCookie(res, 'registeredStudent', JSON.stringify(registeredStudent)) return registeredStudent}// server/api/student/get-dataimport type { IncomingMessage, ServerResponse } from 'http'import { useCookies } from 'h3exportdefaultasync(req: IncomingMessage,res: ServerResponse)=>{returnuseCookies(req)}// pages/student/confirm-user-registration<scriptsetuplang="ts">const{ data }=awaituseAsyncData('get-user-data',()=>$fetch('/api/student/get-data'))console.log(data.value)// this works on router navigation within the browser// But it doesn't work on page reload </script>
I need to get the data before Vue renders the page
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered:
Environment
Reproduction
nil
Describe the bug
Having a page where I need to get user's session/cookie data from the server/backend:
Firstly, on SSR, there is no Cookie on useNuxtApp().ssrContext.req.headers! (This would have sufficed for my use case)
secondly, I tried a workaround option like this
I need to get the data before Vue renders the page
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: