Skip to content

Commit ab4fe02

Browse files
committed
fix(profile): filter out empty pronouns from response
1 parent 9d75c60 commit ab4fe02

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/pages/settings/profile.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,14 @@ type Props = SSRProps<{
497497
}>;
498498

499499
export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {
500-
// eslint-disable-next-line react-hooks/rules-of-hooks
501-
const res = await fetch('https://api.stats.fm/api/v1/me/available-pronouns')
502-
.then((res) => res.json())
503-
.then((res) => res.items);
504-
const pronouns = Object.values(res).flat() as Pronoun[];
505500
const user = await fetchUser(ctx);
501+
const pronounsResponse = await fetch(
502+
'https://api.stats.fm/api/v1/me/available-pronouns',
503+
);
504+
const { items: pronounsItems } = await pronounsResponse.json();
505+
const pronouns = Object.values<Pronoun>(pronounsItems).filter(
506+
({ aliases }) => aliases.length !== 0,
507+
);
506508

507509
return {
508510
props: {

0 commit comments

Comments
 (0)