Update auth-test.tsx

This commit is contained in:
Steve Ruiz 2021-06-19 19:27:15 +01:00
parent 22eaf217da
commit 00fe07c6c3

View file

@ -51,17 +51,19 @@ export default function Home({
export async function getServerSideProps(context: GetServerSidePropsContext) { export async function getServerSideProps(context: GetServerSidePropsContext) {
const session = await getSession(context) const session = await getSession(context)
const id = session?.user?.image.match(/u\/(.*)\?/)?.[1]
const sponsors = await fetch( const sponsors = await fetch(
'https://sponsors.trnck.dev/sponsors/steveruizok' 'https://sponsors.trnck.dev/sponsors/steveruizok'
).then((d) => d.json().then((d) => d.sponsors)) ).then((d) => d.json().then((d) => d.sponsors))
const sponsor = sponsors.find( const sponsor = sponsors.find((sponsor: { avatar: string }) =>
(sponsor: { avatar: string }) => sponsor.avatar === session?.user?.image sponsor.avatar.includes(id)
) )
console.log( console.log(
session?.user, session?.user,
session?.user?.image, id,
sponsors.map((sponsor: any) => sponsor.avatar) sponsors.map((sponsor: any) => sponsor.avatar)
) )