mirror of
https://github.com/vercel/commerce.git
synced 2025-08-16 13:51:24 +00:00
.vscode
assets
components
config
framework
bigcommerce
commerce
shopify
swell
api
auth
cart
common
customer
product
utils
customer-token.ts
get-categories.ts
get-checkout-id.ts
get-search-variables.ts
get-sort-variables.ts
get-vendors.ts
handle-fetch-response.ts
handle-login.ts
index.ts
normalize.ts
storage.ts
wishlist
.env.template
commerce.config.json
const.ts
fetcher.ts
index.tsx
next.config.js
provider.ts
schema.d.ts
schema.graphql
swell-js.d.ts
types.ts
vendure
lib
pages
public
.editorconfig
.env.template
.gitignore
.prettierignore
.prettierrc
README.md
codegen.json
commerce.config.json
global.d.ts
license.md
next-env.d.ts
next.config.js
package.json
postcss.config.js
tailwind.config.js
tsconfig.json
yarn.lock
* Improved Categories * Improved Categories * Improved Categories * Improved Categories * Improved Categories * Improved Categories
17 lines
384 B
TypeScript
17 lines
384 B
TypeScript
import { SwellConfig } from '../api'
|
|
import { Category } from '@commerce/types'
|
|
|
|
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
|