Skip to content

Commit

Permalink
feat: new api to get the product list (#114)
Browse files Browse the repository at this point in the history
New api getProducts
  • Loading branch information
raphodn authored Jan 7, 2024
1 parent 2ad1d2c commit 4504f4e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ export default {
.then((response) => response.json())
},

getProducts(params = {}) {
const defaultParams = {page: 1, size: 10} // order_by default ?
const url = `${import.meta.env.VITE_OPEN_PRICES_API_URL}/products?${new URLSearchParams({...defaultParams, ...params})}`
return fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.then((response) => response.json())
},

getProductById(productId) {
const url = `${import.meta.env.VITE_OPEN_PRICES_API_URL}/products/${productId}`
return fetch(url, {
Expand Down

0 comments on commit 4504f4e

Please sign in to comment.