forked from mirrors/pronouns.cc
fix(frontend): remove redundant member list fetch
This commit is contained in:
parent
befd3f15ee
commit
3a640e4bcd
1 changed files with 3 additions and 13 deletions
|
@ -8,25 +8,15 @@ interface Props {
|
|||
partialMembers: PartialMember[];
|
||||
}
|
||||
|
||||
export default function Index({ user, partialMembers }: Props) {
|
||||
export default function Index({ user }: Props) {
|
||||
return <PersonPage person={user} />;
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||
const name = context.params!.user;
|
||||
try {
|
||||
const [userResponse, partialMembersResponse] = await Promise.allSettled([
|
||||
fetchAPI<User>(`/users/${name}`),
|
||||
fetchAPI<PartialMember[]>(`/users/${name}/members`),
|
||||
]);
|
||||
if (userResponse.status === "rejected")
|
||||
throw new Error("Could not fetch user");
|
||||
const user = userResponse.value;
|
||||
const partialMembers =
|
||||
partialMembersResponse.status === "fulfilled"
|
||||
? partialMembersResponse.value
|
||||
: [];
|
||||
return { props: { user, partialMembers } };
|
||||
const user = await fetchAPI<User>(`/users/${name}`);
|
||||
return { props: { user } };
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { notFound: true };
|
||||
|
|
Loading…
Reference in a new issue