Skip to content

Commit

Permalink
added user
Browse files Browse the repository at this point in the history
  • Loading branch information
RyamL1221 committed Dec 9, 2024
1 parent b0eeb62 commit d38c81d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/lib/api/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use server';

import { auth } from '@/auth';
import { ENDPOINTS } from './endpoints';

export async function GetUser(email: string) {
const session = await auth();
if (!session?.user) return { error: 'Please log in', response: '' };

const resp = await fetch(ENDPOINTS.userData, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
auth_email: session.user.email,
auth_token: session.user.name,
email,
}),
});

const resJSON = await resp.json();
if (resp.status === 200) return { error: '', response: resJSON };
return { error: resJSON, response: '' };
}

0 comments on commit d38c81d

Please sign in to comment.