4
0
forked from crowetic/commerce
commerce/framework/shopify/api/operations/get-all-collections.ts
Peter Mekhaeil 300d04c1ac
Shopify Provider (#186)
* Start of Shopify provider

* add missing comment to documentation

* add missing env vars to documentation

* update reference to types file
2021-02-12 11:14:16 -03:00

22 lines
464 B
TypeScript

import Client from 'shopify-buy'
import { ShopifyConfig } from '../index'
type Options = {
config: ShopifyConfig
}
const getAllCollections = async (options: Options) => {
const { config } = options
const client = Client.buildClient({
storefrontAccessToken: config.apiToken,
domain: config.commerceUrl,
})
const res = await client.collection.fetchAllWithProducts()
return JSON.parse(JSON.stringify(res))
}
export default getAllCollections