[bugfix] remove leading zeros from number
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user