Code Room
Code reviewMediumcr-g308
Subject IdempotencyLevel Mid–Senior~18 minCommon in Networking & APIs interviewsIndustries Software development

Question

Review this JavaScript client that sends an idempotency key with each retry of a refund request.

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.

Talk through your review
Code to reviewjs
async function refund(orderId, amount) {  for (let i = 0; i < 3; i++) {    const key = crypto.randomUUID();    const res = await fetch("/refunds", {      method: "POST",      headers: { "Idempotency-Key": key },      body: JSON.stringify({ orderId, amount }),    });    if (res.ok) return res.json();  }  throw new Error("refund failed");}
Run or narrate your approach, then ask the coach.