feat: added a function for post and delete that follows callApi that only does get

This commit is contained in:
Mohamed Maoulainine Maoulainine 2025-04-09 00:09:58 +02:00
parent 647812576e
commit 84d8d4523b

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 };