Skip to content

Commit

Permalink
Add new api getProducts
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jan 7, 2024
1 parent e660b7d commit bb57d4a
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}
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 bb57d4a

Please sign in to comment.