Use Swell REST API for fetching products

This commit is contained in:
2022-09-18 17:10:06 +02:00
parent 2393d28597
commit c7b67b909c
4 changed files with 24 additions and 39 deletions

View File

@@ -65,35 +65,4 @@ export const removeCartItem = async (productId: string) => {
if (updatedCart) {
return updatedCart
}
}
/**
* Fetch products
*/
export const getProducts = async (category?: string, limit: number = 25, page: number = 1) => {
const products = await swell.products.list({
where: {
active: true,
},
category,
limit,
page
})
if (products) {
return products
}
}
/**
* Retrieve a product
*/
export const getProduct = async (id: string) => {
const product = await swell.products.get(id)
if (product) {
return product
}
}