Skip to content

Commit

Permalink
correct typing
Browse files Browse the repository at this point in the history
  • Loading branch information
teleaziz committed May 24, 2021
1 parent fa61191 commit b9ac722
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions lib/shopify/storefront-data-hooks/src/api/operations-builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { BuilderContent } from '@builder.io/react'
import * as qs from 'qs'

export interface BuillderConfig {
Expand All @@ -20,13 +19,13 @@ export async function getAllProducts(
limit = 100,
offset = 0
) {
const productsContent: BuilderContent[] = (
const productsContent = (
await fetch(
`https://cdn.builder.io/api/v2/content/${config.productsModel}?apiKey=${config.apiKey}&limit=${limit}&offset=${offset}`
).then((res) => res.json())
).results

return productsContent.map((pr) => pr.data)
return productsContent.map((pr: any) => pr.data)
}

export async function searchProducts(
Expand All @@ -45,7 +44,7 @@ export async function searchProducts(
{ allowDots: true }
)

const productsContent: BuilderContent[] = (
const productsContent = (
await fetch(
`https://cdn.builder.io/api/v2/content/${
config.productsModel
Expand All @@ -55,7 +54,7 @@ export async function searchProducts(
})}`
).then((res) => res.json())
).results
return productsContent?.map((product) => product.data) || []
return productsContent?.map((product: any) => product.data) || []
}

export async function getAllProductPaths(
Expand Down Expand Up @@ -87,7 +86,7 @@ export async function getProduct(
},
})

const productsContent: BuilderContent[] = (
const productsContent = (
await fetch(
`https://cdn.builder.io/api/v2/content/${config.productsModel}?${query}`
).then((res) => res.json())
Expand Down Expand Up @@ -119,13 +118,13 @@ export async function getAllCollections(
{ allowDots: true }
)

const collectionsContent: BuilderContent[] = (
const collectionsContent = (
await fetch(
`https://cdn.builder.io/api/v2/content/${config.collectionsModel}?${query}`
).then((res) => res.json())
).results

return collectionsContent?.map((entry) => entry.data) || []
return collectionsContent?.map((entry: any) => entry.data) || []
}

export async function searchCollections(
Expand All @@ -144,7 +143,7 @@ export async function searchCollections(
{ allowDots: true }
)

const collectionsContent: BuilderContent[] = (
const collectionsContent = (
await fetch(
`https://cdn.builder.io/api/v2/content/${
config.collectionsModel
Expand All @@ -158,7 +157,7 @@ export async function searchCollections(
])}`
).then((res) => res.json())
).results
return collectionsContent?.map((entry) => entry.data) || []
return collectionsContent?.map((entry: any) => entry.data) || []
}

export async function getAllCollectionPaths(
Expand Down Expand Up @@ -195,7 +194,7 @@ export async function getCollection(
},
})

const collectionsContent: BuilderContent[] = (
const collectionsContent = (
await fetch(
`https://cdn.builder.io/api/v2/content/${config.collectionsModel}?${query}`
).then((res) => res.json())
Expand All @@ -207,7 +206,7 @@ export async function getCollection(
}
const productsQuery = {
limit: 20,
handle: collection.handle,
handle: collection?.handle,
...options.productsQuery,
apiKey: config.apiKey,
}
Expand Down
2 changes: 1 addition & 1 deletion pages/product/[handle].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function Handle({
) : (
<BuilderComponent
isStatic
key={product.id}
key={product!.id}
model={builderModel}
data={{ product, theme }}
{...(page && { content: page })}
Expand Down

0 comments on commit b9ac722

Please sign in to comment.