Skip to content

Commit

Permalink
Remove any type and make removeEdgesAndNodes generic
Browse files Browse the repository at this point in the history
  • Loading branch information
harrybuisman committed Jul 14, 2024
1 parent 7fd9ad8 commit e2da7ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/shopify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function shopifyFetch<T>({
}
}

const removeEdgesAndNodes = (array: Connection<any>) => {
const removeEdgesAndNodes = <T>(array: Connection<T>): T[] => {
return array.edges.map((edge) => edge?.node);
};

Expand Down Expand Up @@ -163,7 +163,7 @@ const reshapeImages = (images: Connection<Image>, 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}`
Expand Down

0 comments on commit e2da7ee

Please sign in to comment.