Get a category of products from Swell

This commit is contained in:
2021-11-08 13:24:33 +01:00
parent 378a64f2b0
commit 75f3e5f1d1
4 changed files with 59 additions and 20 deletions

View File

@@ -5,6 +5,25 @@ swell.init(import.meta.env.VITE_SWELL_STORE_ID, import.meta.env.VITE_SWELL_API_T
/**
* Fetch products
*/
export const getProducts = async (category?: string, limit: number = 25, page: number = 1) => {
const products = await swell.get('/products', {
where: {
active: true,
},
category,
limit,
page
})
if (products) {
return products
}
}
/**
* Retrieve a product
*/