Retry flaky payment-status calls

Node · Node · intermediate · greenfield

Adds automatic retries to the payment-status call. Passes axios a retries option so a failed request is retried up to 3 times before it throws. Confirmed the happy path returns the status object.

Called during checkout. A shared setup module sets axios.defaults.baseURL to the provider, so the relative path resolves; the provider intermittently returns 503s under load.

Requirements

Files touched

--- src/payments/status.js
+const axios = require('axios');
+
+async function getPaymentStatus(paymentId) {
+  const res = await axios.get(`/payments/${paymentId}/status`, {
+    retries: 3,
+  });
+  return res.data;
+}
+
+module.exports = { getPaymentStatus };

Review this PR

Node practice