async function verifyWithRetry(payload, maxAttempts = 3) {
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
const res = await fetch("https://api.check.et/api/v1/verify", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CHECK_ET_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
})
if (res.status !== 500 && res.status !== 429) {
return res.json()
}
const delay = Math.min(1000 * 2 ** attempt, 30000)
await new Promise((r) => setTimeout(r, delay))
}
throw new Error("Max retry attempts reached")
}