1
0
mirror of https://github.com/vercel/commerce.git synced 2025-07-22 20:26:49 +00:00
Files
commerce/framework/swell/utils/get-categories.ts
2021-05-13 16:10:09 +03:00

21 lines
422 B
TypeScript

import { SwellConfig } from '../api'
export type Category = {
entityId: string
name: string
path: string
}
const getCategories = async (config: SwellConfig): Promise<Category[]> => {
const data = await config.fetch('categories', 'get')
return (
data.results.map(({ id: entityId, name, slug }: any) => ({
entityId,
name,
path: `/${slug}`,
})) ?? []
)
}
export default getCategories