mirror of
https://github.com/vercel/commerce.git
synced 2025-03-28 00:05:53 +00:00
21 lines
426 B
TypeScript
21 lines
426 B
TypeScript
import { SwellConfig } from '../api'
|
|
|
|
export type Category = {
|
|
id: string
|
|
name: string
|
|
slug: string
|
|
}
|
|
|
|
const getCategories = async (config: SwellConfig): Promise<Category[]> => {
|
|
const data = await config.fetchSwell('categories', 'get')
|
|
return (
|
|
data.results.map(({ id: entityId, name, slug }: Category) => ({
|
|
entityId,
|
|
name,
|
|
path: `/${slug}`,
|
|
})) ?? []
|
|
)
|
|
}
|
|
|
|
export default getCategories
|