We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7fd9ad8 commit 7c1b34aCopy full SHA for 7c1b34a
lib/shopify/index.ts
@@ -114,7 +114,7 @@ export async function shopifyFetch<T>({
114
}
115
116
117
-const removeEdgesAndNodes = (array: Connection<any>) => {
+const removeEdgesAndNodes = <T>(array: Connection<T>): T[] => {
118
return array.edges.map((edge) => edge?.node);
119
};
120
@@ -163,7 +163,7 @@ const reshapeImages = (images: Connection<Image>, productTitle: string) => {
163
const flattened = removeEdgesAndNodes(images);
164
165
return flattened.map((image) => {
166
- const filename = image.url.match(/.*\/(.*)\..*/)[1];
+ const filename = image.url.match(/.*\/(.*)\..*/)?.[1];
167
return {
168
...image,
169
altText: image.altText || `${productTitle} - ${filename}`
0 commit comments