aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-26 21:21:03 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-26 21:21:03 +0530
commit55aed6d7c2df0daedbdabea0d1727acb1815ce2b (patch)
tree42dabdc4f68bd01867cd84c4a9beaa6a14ffb9c2 /src/utils
parent4833cc911b004b3da476863ddf27e09d93dd89c0 (diff)
downloadadmin-panel-55aed6d7c2df0daedbdabea0d1727acb1815ce2b.tar.gz
admin-panel-55aed6d7c2df0daedbdabea0d1727acb1815ce2b.tar.bz2
admin-panel-55aed6d7c2df0daedbdabea0d1727acb1815ce2b.zip
added upload feature
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/api.js39
1 files changed, 14 insertions, 25 deletions
diff --git a/src/utils/api.js b/src/utils/api.js
index 1f8e92d..7b63aa4 100644
--- a/src/utils/api.js
+++ b/src/utils/api.js
@@ -1,32 +1,21 @@
-const API_URL = 'http://localhost:5000'; // Replace with your actual API URL
-
export const fetchAds = async () => {
- try {
- const response = await fetch(`${API_URL}/ads`);
- if (!response.ok) {
- throw new Error('Network response was not ok');
- }
- return await response.json();
- } catch (error) {
- console.error('Error fetching ads:', error);
- return [];
+ const response = await fetch('http://localhost:5000/ads');
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
}
+ return response.json();
};
export const addAd = async (ad) => {
- try {
- const response = await fetch(`${API_URL}/ads`, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(ad),
- });
- if (!response.ok) {
- throw new Error('Network response was not ok');
- }
- return await response.json();
- } catch (error) {
- console.error('Error adding ad:', error);
+ const response = await fetch('http://localhost:5000/ads', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(ad),
+ });
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
}
+ return response.json();
};