Code RoomConcurrent checkout requests
MediumPrep Room Coding #1822

Concurrent checkout requests

Code reviewNetworking & APIsConcurrencyMid–Senior~20 min

Review this React TypeScript component.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1function CheckoutButton({ cartId }: { cartId: string }) {
2 const [done, setDone] = useState(false);
3 
4 const pay = async () => {
5 const res = await fetch('/api/checkout', {
6 method: 'POST',
7 body: JSON.stringify({ cartId }),
8 });
9 if (res.ok) setDone(true);
10 };
11 
12 return <button onClick={pay} disabled={done}>Pay now</button>;
13}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.