|
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.3 KB
|
| Line | |
|---|
| 1 | import axios from "axios";
|
|---|
| 2 |
|
|---|
| 3 | const menuItemRoute = "/menu-items";
|
|---|
| 4 |
|
|---|
| 5 | const GetAllMenuItems = async () => {
|
|---|
| 6 | try {
|
|---|
| 7 | const response = await axios.get(menuItemRoute);
|
|---|
| 8 | return response.data;
|
|---|
| 9 | } catch (error) {
|
|---|
| 10 | console.error("Error fetching restaurants:", error);
|
|---|
| 11 | }
|
|---|
| 12 | };
|
|---|
| 13 |
|
|---|
| 14 | const GetMenuItem = async (id) => {
|
|---|
| 15 | try {
|
|---|
| 16 | const response = await axios.get(`${menuItemRoute}/${id}`);
|
|---|
| 17 | return response.data;
|
|---|
| 18 | } catch (error) {
|
|---|
| 19 | console.error("Error fetching restaurants:", error);
|
|---|
| 20 | }
|
|---|
| 21 | };
|
|---|
| 22 |
|
|---|
| 23 | const CreateMenuItem = async (formData) => {
|
|---|
| 24 | try {
|
|---|
| 25 | const response = await axios.post(`${menuItemRoute}`, formData);
|
|---|
| 26 | return response.data;
|
|---|
| 27 | } catch (error) {
|
|---|
| 28 | console.error("Error occured", error);
|
|---|
| 29 | }
|
|---|
| 30 | };
|
|---|
| 31 |
|
|---|
| 32 | const UpdateMenuItem = async (id, formData) => {
|
|---|
| 33 | try {
|
|---|
| 34 | const response = await axios.post(`${menuItemRoute}/${id}`, formData);
|
|---|
| 35 | return response.data;
|
|---|
| 36 | } catch (error) {
|
|---|
| 37 | console.error("Error occured", error);
|
|---|
| 38 | }
|
|---|
| 39 | };
|
|---|
| 40 |
|
|---|
| 41 | const DeleteMenuItem = async (id) => {
|
|---|
| 42 | try {
|
|---|
| 43 | const response = await axios.delete(`${menuItemRoute}/${id}`);
|
|---|
| 44 | return response.data;
|
|---|
| 45 | } catch (error) {
|
|---|
| 46 | console.error("Error occured", error);
|
|---|
| 47 | }
|
|---|
| 48 | };
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | export {GetAllMenuItems, GetMenuItem, CreateMenuItem, UpdateMenuItem, DeleteMenuItem} |
|---|
Note:
See
TracBrowser
for help on using the repository browser.