feat: added a function for post and delete that follows callApi that only does get
This commit is contained in:
parent
647812576e
commit
84d8d4523b
@ -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 };
|
||||
|
Loading…
x
Reference in New Issue
Block a user