[bugfix] remove leading zeros from number

This commit is contained in:
2026-05-28 21:15:29 -04:00
parent 2cf47d2b15
commit 9afc600e63
3 changed files with 27 additions and 8 deletions

View File

@@ -76,11 +76,30 @@ const syncProductLine = async (
log(` - ${item.productName} (ID: ${item.productId})`);
const detailResponse = await fetch(`https://mp-search-api.tcgplayer.com/v2/product/${item.productId}/details`, {
method: 'GET',
});
if (!detailResponse.ok) {
throw new Error(`Error fetching product details for ${item.productId}: ${detailResponse.statusText}`);
let detailResponse: Response | null = null;
let lastError: unknown = null;
for (let attempt = 1; attempt <= 3; attempt++) {
try {
const r = await fetch(`https://mp-search-api.tcgplayer.com/v2/product/${item.productId}/details`, {
method: 'GET',
});
if (r.ok) {
detailResponse = r;
break;
}
lastError = new Error(`Error fetching product details for ${item.productId}: ${r.statusText}`);
} catch (err) {
lastError = err;
}
if (attempt < 3) {
log(` retry ${attempt}/2 for product ${item.productId} in 5s...`);
await helper.Sleep(5000);
}
}
if (!detailResponse) {
throw lastError instanceof Error
? lastError
: new Error(`Error fetching product details for ${item.productId}: ${String(lastError)}`);
}
const detailData = await detailResponse.json();