File size: 645 Bytes
308a91d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b5a4916
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import api from './axios';

export const getProducts = (params = {}) =>
  api.get('/api/products/', { params });

export const getProduct = (id) =>
  api.get(`/api/products/${id}`);

export const createProduct = (data) =>
  api.post('/api/products/', data);

export const updateProduct = (id, data) =>
  api.put(`/api/products/${id}`, data);

export const deleteProduct = (id) =>
  api.delete(`/api/products/${id}`);

export const uploadProductImage = (file) => {
  const form = new FormData();
  form.append('file', file);
  return api.post('/api/products/upload-image', form, {
    headers: { 'Content-Type': 'multipart/form-data' },
  });
};