Files
sgeUpdated/sge-frontend/src/services/ApplicationService.js
Khaled Elagamy 85f1847070 Add 'sge-frontend/' from commit '5fa787e054b25ac53edc7ff0275ea7960a709401'
git-subtree-dir: sge-frontend
git-subtree-mainline: 876c278ac4
git-subtree-split: 5fa787e054
2025-08-04 00:27:23 +03:00

78 lines
1.6 KiB
JavaScript

import axiosConf, {baseURL} from "../configs/@axios";
import axios from "axios";
class ApplicationService {
get url() {
return process.env.REACT_APP_API_BASE_URL;
};
get webSocketUrl() {
return process.env.REACT_APP_API_WEBSOCKET_BASE_URL;
};
http = () => {
return axiosConf;
};
httpWithoutAuthorization = () => {
return axios.create({
baseURL,
});
}
get = (url) => {
return new Promise((resolve, reject) => {
return this.http()
.get(url)
.then((data) => {
resolve(data.data);
})
.catch((err) => {
reject(err);
});
});
};
post = (url, data, config) => {
return new Promise((resolve, reject) => {
return this.http()
.post(url, data, config)
.then((data) => {
resolve(data.data);
})
.catch((err) => {
reject(err);
});
});
};
put = (url, data, config) => {
return new Promise((resolve, reject) => {
return this.http()
.put(url, data, config)
.then((data) => {
resolve(data.data);
})
.catch((err) => {
reject(err);
});
});
};
delete = (url) => {
return new Promise((resolve, reject) => {
return this.http()
.delete(url)
.then((data) => {
resolve(data.data);
})
.catch((err) => {
reject(err);
});
});
};
}
const instance = new ApplicationService();
export default instance;