Next.js Discord

Discord Forum

GetServersideProps vs NextAPI Patterns

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Avatar
Asian black bearOP
In my project I'm querying member data from an AWS service using a token provided by Next-Auth/Cognito. 1.) I'm finding I'm having to repeat this pattern pretty frequently which makes me wonder if I'm doing this wrong. Is there a more DRY way of passing the token to the fetchMemberById function?
2.) I thought this would be the point to reach for Next API endpoints but I'm reading conflicting content about how it might be inefficient to what I'm currently doing?
 const session = await getSession(context);
  const token = session?.accessToken as string;
  const { id } = context.params ?? {};
  const profileRaw = await fetchMemberById({ id, token });

0 Replies