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
export default async function createMembershipApi(
req: NextApiRequest,
res: NextApiResponse
) {
try {
cheReqMethod(req, res, 'POST');
const secret = process.env.NEXTAUTH_SECRET;
const session = (await getToken({
req,
secret,
})) as { user: UserProfile } | null;
console.log(session);
if (!session) return res.status(403).json({ message: 'unauthorized' });
const { user } = session;
return res.status(200).json({ user });
} catch (e: any) {
logOnDevEnv(e);
if ('message' in e) {
return res.status(500).json({ message: e.message });
}
return res.status(500).json({ message: 'something went wrong' });
}
}
However I'm not getting the session from the getToken method. I have looked for an answer but so far I've only come across some implementations involving react-testing-library. My intention is only testing the api's.
If anyone has dealed with this or can point me in the right direction I would really appreciate it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm trying to test my api's individually like this:
And inside my api I have this:
However I'm not getting the session from the getToken method. I have looked for an answer but so far I've only come across some implementations involving react-testing-library. My intention is only testing the api's.
If anyone has dealed with this or can point me in the right direction I would really appreciate it.
Beta Was this translation helpful? Give feedback.
All reactions