source: frontend/src/services/restoran-service.jsx@ badbc79

Last change on this file since badbc79 was badbc79, checked in by Luka Cheshlarov <luka.cheshlarov@…>, 20 months ago

Initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import axios from "axios";
2
3const restorantRoute = "/restorants";
4
5const GetAllRestaurants = async () => {
6 try {
7 const response = await axios.get(restorantRoute);
8 return response.data;
9 } catch (error) {
10 console.error("Error fetching restaurants:", error);
11 }
12};
13
14const GetRestourant = async (id) => {
15 try {
16 const response = await axios.get(`${restorantRoute}/${id}`);
17 return response.data;
18 } catch (error) {
19 console.error("Error fetching restaurants:", error);
20 }
21};
22
23const CreateRestorant = async (formData) => {
24 try {
25 const response = await axios.post(`${restorantRoute}`, formData);
26 return response.data;
27 } catch (error) {
28 console.error("Error occured", error);
29 }
30};
31
32const UpdateRestorant = async (id, formData) => {
33 try {
34 const response = await axios.post(`${restorantRoute}/${id}`, formData);
35 return response.data;
36 } catch (error) {
37 console.error("Error occured", error);
38 }
39};
40
41
42export {GetAllRestaurants, GetRestourant, CreateRestorant, UpdateRestorant}
Note: See TracBrowser for help on using the repository browser.