connected with backups and currency rates
This commit is contained in:
1 parent
d8e903f24c
commit
5884ec831c
18 files changed
+893
-526
No files matched your search
+12
-8
@@ -52,10 +52,19 @@ apiClient.interceptors.request.use(
|
||||
);
|
||||
|
||||
apiClient.interceptors.response.use(
|
||||
// Başarılı response'larda envelope'u soyup direkt `data`yı döndürüyoruz.
|
||||
// Böylece feature API fonksiyonları `response.data.data` yerine `response.data` yazar.
|
||||
(response) => {
|
||||
response.data = (response.data as ApiSuccessResponse<unknown>)?.data;
|
||||
if (
|
||||
response.config.responseType === "blob" ||
|
||||
response.config.responseType === "arraybuffer" ||
|
||||
response.data instanceof Blob ||
|
||||
response.data instanceof ArrayBuffer
|
||||
) {
|
||||
return response;
|
||||
}
|
||||
|
||||
if (response.data && typeof response.data === "object" && "data" in response.data) {
|
||||
response.data = (response.data as ApiSuccessResponse<unknown>)?.data;
|
||||
}
|
||||
return response;
|
||||
},
|
||||
async (error: AxiosError<ApiErrorResponse>) => {
|
||||
@@ -102,11 +111,6 @@ apiClient.interceptors.response.use(
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Backend'in standart hata mesajını çıkarır.
|
||||
* QueryCache.onError / MutationCache.onError içinde toast.error() için kullanılacak.
|
||||
*/
|
||||
export function extractErrorMessage(error: unknown, fallback = "Bir hata oluştu"): string {
|
||||
if (axios.isAxiosError<ApiErrorResponse>(error)) {
|
||||
return error.response?.data?.message || fallback;
|
||||
|
||||
Reference in new issue
Block a user