Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the PNID's Stripe tier name and level from the PNID details API #128

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/services/api/routes/v1/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ router.get('/', async (request: express.Request, response: express.Response): Pr
connections: {
discord: {
id: pnid.connections.discord.id
},
stripe: {
tier_name: pnid.connections.stripe.tier_name,
tier_level: pnid.connections.stripe.tier_level
Comment on lines +67 to +68
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what the types are here, but I reckon connections, and stripe can be undefined, which would cause an error.

I would suggest either:
a) use a ternary to say stripe: pnid.connections?.stripe ? { ... } : null
b) use optional chaining on the properties, i.e pnid.connections?.stripe?.tier_name

Option a) would give the stripe object the possibility to be null, and option b) would ensure the object would always be present but with possibly null values.

}
}
});
Expand Down
Loading