commerce/framework/swell/utils/get-categories.ts
ghoskin 4d85b43a30
Update Swell Provider (#359)
* fix update cart item

* update types

* update checkout

* update get-page, cleanup types

* revert change to incorrect file

* cleanup

Co-authored-by: Greg Hoskin <greghoskin@Gregs-MacBook-Pro.local>
2021-06-14 17:37:18 -03:00

17 lines
382 B
TypeScript

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