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[];
|
partialMembers: PartialMember[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Index({ user, partialMembers }: Props) {
|
export default function Index({ user }: Props) {
|
||||||
return <PersonPage person={user} />;
|
return <PersonPage person={user} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
const name = context.params!.user;
|
const name = context.params!.user;
|
||||||
try {
|
try {
|
||||||
const [userResponse, partialMembersResponse] = await Promise.allSettled([
|
const user = await fetchAPI<User>(`/users/${name}`);
|
||||||
fetchAPI<User>(`/users/${name}`),
|
return { props: { user } };
|
||||||
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 } };
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
return { notFound: true };
|
return { notFound: true };
|
||||||
|
|
Loading…
Reference in a new issue