commerce/framework/csv/product/get-all-product-paths.ts
2021-04-18 14:51:03 -03:00

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