mirror of
https://github.com/vercel/commerce.git
synced 2025-03-14 06:32:32 +00:00
Remove any type and make removeEdgesAndNodes generic (#1353)
This commit is contained in:
parent
7fd9ad8a8c
commit
7c1b34abdb
@ -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);
|
||||
};
|
||||
|
||||
@ -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}`
|
||||
|
Loading…
x
Reference in New Issue
Block a user