mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 05:31:22 +00:00
28 lines
481 B
TypeScript
28 lines
481 B
TypeScript
import api from '../api/product'
|
|
|
|
interface ProductPath {
|
|
node: {
|
|
path: string
|
|
}
|
|
}
|
|
|
|
interface GetAllProductPaths {
|
|
products: ProductPath[]
|
|
}
|
|
|
|
const getAllProductPaths = async (): Promise<GetAllProductPaths> => {
|
|
const products = await api.list().then((products) =>
|
|
products.map((product) => ({
|
|
node: {
|
|
path: product.path || product.id,
|
|
},
|
|
}))
|
|
)
|
|
|
|
return {
|
|
products: products as ProductPath[],
|
|
}
|
|
}
|
|
|
|
export default getAllProductPaths
|