import axios from "axios"; export function postAuxEnd(uri:string, reqData:any):Promise { const endPoint = import.meta.env.VITE_APP_USER_ENDPOINT + uri; const formData = new FormData(); for (let value in reqData) { formData.append(value, reqData[value]); } return axios.post(endPoint, formData) .then((response) => { console.log(response); // if (response.data.internal_return == "-9999") { // localStorage.clear(); // window.location.href = `/login?sessionExpired=true`; // } return response; }) .catch((error) => { if (error.response) { //response status is an error code console.log( "ERROR-------------------------------------------------------" ); console.log(error.response.status); console.log( "ERROR-------------------------------------------------------" ); } else if (error.request) { //response not received though the request was sent console.log( "ERROR2-------------------------------------------------------" ); console.log(error?.request); console.log( "ERROR2-------------------------------------------------------" ); } else { //an error occurred when setting up the request console.log( "ERROR3-------------------------------------------------------" ); console.log(error); console.log( "ERROR3-------------------------------------------------------" ); } }); } export function patchAuxEnd(uri:string, reqData:any):Promise { const endPoint = import.meta.env.VITE_APP_USER_ENDPOINT + uri; const formData = new FormData(); for (let value in reqData) { formData.append(value, reqData[value]); } return axios.patch(endPoint, formData) .then((response) => { console.log(response); // if (response.data.internal_return == "-9999") { // localStorage.clear(); // window.location.href = `/login?sessionExpired=true`; // } return response; }) .catch((error) => { if (error.response) { //response status is an error code console.log( "ERROR-------------------------------------------------------" ); console.log(error.response.status); console.log( "ERROR-------------------------------------------------------" ); } else if (error.request) { //response not received though the request was sent console.log( "ERROR2-------------------------------------------------------" ); console.log(error?.request); console.log( "ERROR2-------------------------------------------------------" ); } else { //an error occurred when setting up the request console.log( "ERROR3-------------------------------------------------------" ); console.log(error); console.log( "ERROR3-------------------------------------------------------" ); } }); } export function getAuxEnd(uri: string, reqData?: any): Promise { const endPoint = import.meta.env.VITE_APP_USER_ENDPOINT + uri; const formData = new FormData(); for (let value in reqData) { formData.append(value, reqData[value]); } return axios .get(endPoint, reqData) .then((response: {}) => { // if (response.data.internal_return == "-9999") { // localStorage.clear(); // window.location.href = `/login?sessionExpired=true`; // } return response; }) .catch((error: any) => { console.log( "ERROR3-------------------------------------------------------", error ); }); }