Compare commits

...

2 Commits

Author SHA1 Message Date
Mohamed Maoulainine Maoulainine
b9647ce36e Merge branch 'front_foundation' of https://gitea.piair.dev/piair/MyINPulse into front_foundation
Some checks failed
Format / formatting (push) Successful in 5s
Build / build (push) Successful in 38s
CI / build (push) Failing after 8s
Format / formatting (pull_request) Successful in 5s
2025-04-09 00:10:04 +02:00
Mohamed Maoulainine Maoulainine
84d8d4523b feat: added a function for post and delete that follows callApi that only does get 2025-04-09 00:09:58 +02:00

View File

@ -65,4 +65,28 @@ function callApi(
);
}
export { callApi };
function postApi(
endpoint: string,
data: any,
onSuccessHandler?: (response: AxiosResponse) => void,
onErrorHandler?: (error: AxiosError) => void
): void {
axiosInstance
.post(endpoint, data)
.then(onSuccessHandler ?? defaultApiSuccessHandler)
.catch(onErrorHandler ?? defaultApiErrorHandler);
}
function deleteApi(
endpoint: string,
onSuccessHandler?: (response: AxiosResponse) => void,
onErrorHandler?: (error: AxiosError) => void
): void {
axiosInstance
.delete(endpoint)
.then(onSuccessHandler ?? defaultApiSuccessHandler)
.catch(onErrorHandler ?? defaultApiErrorHandler);
}
export { callApi, postApi, deleteApi };