Remove uneeded try/catch
This commit is contained in:
@@ -130,32 +130,28 @@ export class PrintfulService {
|
|||||||
const allPrintfulOrders: Printful.Orders.Order[] = [];
|
const allPrintfulOrders: Printful.Orders.Order[] = [];
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
const res = await fetch(
|
||||||
const res = await fetch(
|
`${env().API_URL}/orders?offset=${offset}`,
|
||||||
`${env().API_URL}/orders?offset=${offset}`,
|
{
|
||||||
{
|
method: "GET",
|
||||||
method: "GET",
|
headers: { ...env().AUTH_HEADERS },
|
||||||
headers: { ...env().AUTH_HEADERS },
|
},
|
||||||
},
|
);
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new FetchError(
|
||||||
|
"Failed to get all Printful orders",
|
||||||
|
res,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!res.ok) {
|
|
||||||
throw new FetchError(
|
|
||||||
"Failed to get all Printful orders",
|
|
||||||
res,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const payload =
|
|
||||||
(await res.json()) as Printful.Products.MetaDataMulti<Printful.Orders.Order>;
|
|
||||||
|
|
||||||
allPrintfulOrders.push(...payload.result);
|
|
||||||
offset = allPrintfulOrders.length;
|
|
||||||
|
|
||||||
if (allPrintfulOrders.length >= payload.paging.total) break;
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const payload =
|
||||||
|
(await res.json()) as Printful.Products.MetaDataMulti<Printful.Orders.Order>;
|
||||||
|
|
||||||
|
allPrintfulOrders.push(...payload.result);
|
||||||
|
offset = allPrintfulOrders.length;
|
||||||
|
|
||||||
|
if (allPrintfulOrders.length >= payload.paging.total) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return allPrintfulOrders;
|
return allPrintfulOrders;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export class SyncService {
|
|||||||
static async sync(printfulProductId: number | undefined) {
|
static async sync(printfulProductId: number | undefined) {
|
||||||
this.state.isSyncing = true;
|
this.state.isSyncing = true;
|
||||||
|
|
||||||
|
// Populate products
|
||||||
const mainPrintfulProducts: MainProduct[] = [];
|
const mainPrintfulProducts: MainProduct[] = [];
|
||||||
const webflowProducts: Webflow.Products.ProductAndSkus[] = [];
|
const webflowProducts: Webflow.Products.ProductAndSkus[] = [];
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user