Page.tsx
export async function getUser() {
const res = await fetch('http://localhost:3000/api/users/me', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
cookie: cookies().toString(),
},
body: null,
credentials: 'include',
});
if (res.status !== 200) return;
const session = await res.json();
return session;
}
export default async function Page() {
const session = await getUser();
return (
<section>
<LoginForm />
<pre>{JSON.stringify(session, null, 2)}</pre>
</section>
);
}
Page.tsx
export async function getUser() {
const res = await fetch('http://localhost:3000/api/users/me', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
cookie: cookies().toString(),
},
body: null,
credentials: 'include',
});
if (res.status !== 200) return;
const session = await res.json();
return session;
}
export default async function Page() {
const session = await getUser();
return (
<section>
<LoginForm />
<pre>{JSON.stringify(session, null, 2)}</pre>
</section>
);
}