diff --git a/lib/shopify/index.ts b/lib/shopify/index.ts index ca5ddbdb61..a34257bcf3 100644 --- a/lib/shopify/index.ts +++ b/lib/shopify/index.ts @@ -114,7 +114,7 @@ export async function shopifyFetch({ } } -const removeEdgesAndNodes = (array: Connection) => { +const removeEdgesAndNodes = (array: Connection): T[] => { return array.edges.map((edge) => edge?.node); }; @@ -163,7 +163,7 @@ const reshapeImages = (images: Connection, productTitle: string) => { const flattened = removeEdgesAndNodes(images); return flattened.map((image) => { - const filename = image.url.match(/.*\/(.*)\..*/)[1]; + const filename = image.url.match(/.*\/(.*)\..*/)?.[1]; return { ...image, altText: image.altText || `${productTitle} - ${filename}`