forked from BLC/sgeUpdated
Add 'sge-frontend/' from commit '5fa787e054b25ac53edc7ff0275ea7960a709401'
git-subtree-dir: sge-frontend git-subtree-mainline:876c278ac4git-subtree-split:5fa787e054
This commit is contained in:
77
sge-frontend/src/services/ApplicationService.js
Normal file
77
sge-frontend/src/services/ApplicationService.js
Normal file
@@ -0,0 +1,77 @@
|
||||
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;
|
||||
1
sge-frontend/src/services/index.js
Normal file
1
sge-frontend/src/services/index.js
Normal file
@@ -0,0 +1 @@
|
||||
export * from './ApplicationService';
|
||||
Reference in New Issue
Block a user