Files
www-myfit/src/vendors/service/siteService.js
T
dev-chiefworks 3d4328e59f Error catch
2023-01-11 21:05:52 -05:00

61 lines
1.6 KiB
JavaScript

import React from "react";
import Axios from "axios";
class SiteService {
blogData() {
return this.getAuxEnd("blogdata", null);
}
countryData() {}
faqData() {}
getAuxEnd(uri, reqData) {
const endPoint = process.env.REACT_APP_AUX_ENDPOINT + uri;
Axios.get(endPoint)
.then((response) => {
console.log(response);
res = response;
console.log("~~~~~~~ Toks2 GET ~~~~~~~~");
return response;
})
.catch((error) => {
if (error.response) {
//response status is an error code
console.log(error.response.status);
} else if (error.request) {
//response not received though the request was sent
console.log(error.request);
} else {
//an error occurred when setting up the request
console.log(error.message);
}
});
}
getAuxEnd(uri, reqData) {
const endPoint = process.env.REACT_APP_AUX_ENDPOINT + uri;
Axios.post(endPoint)
.then((response) => {
console.log(response);
res = response;
console.log("~~~~~~~ Toks2 POST ~~~~~~~~");
return response;
})
.catch((error) => {
if (error.response) {
//response status is an error code
console.log(error.response.status);
} else if (error.request) {
//response not received though the request was sent
console.log(error.request);
} else {
//an error occurred when setting up the request
console.log(error.message);
}
});
}
}
export default SiteService;