fix: update useApi to return api resualt as promise in addition to set in data
This commit is contained in:
@@ -31,14 +31,16 @@ export function useApi<T, P extends any[]>(
|
||||
const response = await apiFunction(...args);
|
||||
|
||||
setData(response.data);
|
||||
return response.data;
|
||||
} catch (err: unknown) {
|
||||
const axisoError: AxiosError = err as AxiosError;
|
||||
const axiosError: AxiosError = err as AxiosError;
|
||||
console.log(axiosError);
|
||||
|
||||
if (axisoError.response?.status === 401) {
|
||||
if (axiosError.response?.status === 401) {
|
||||
navigate('/login');
|
||||
}
|
||||
|
||||
if (axisoError.response?.status === 500) {
|
||||
if (axiosError.response?.status === 500) {
|
||||
toast({
|
||||
message: t('messages.serverError'),
|
||||
severity: 'error',
|
||||
|
||||
Reference in New Issue
Block a user