Skip to content

Commit

Permalink
Removing correct throw...
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgr committed Oct 4, 2024
1 parent 31ea22f commit 520a4af
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions vtex/loaders/legacy/relatedProductsLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ async function loader(
}, { ...STALE, headers: withSegmentCookie(segment) })
.then((res) => res.json());

if (products && !Array.isArray(products)) {
throw new Error(
`Error while fetching VTEX data ${JSON.stringify(products)}`,
);
}

// unique Ids
const relatedIds = [...new Set(
products.slice(0, count).map((p) => pickSku(p).itemId),
Expand Down Expand Up @@ -120,14 +126,6 @@ async function loader(
);
});

const allPromisesFailed = relatedProductsResults.every(
(result) => result.status === "rejected",
);

if (allPromisesFailed) {
throw new Error("Failed to load related products for all batches.");
}

if (hideUnavailableItems && relatedProducts) {
const inStock = (p: Product) =>
p.offers?.offers.find((o) =>
Expand Down

0 comments on commit 520a4af

Please sign in to comment.