I have a react native expo typescript project and I'm doing authentication. I have axios function:
export type LoginData = { email: string; password: string;}export const loggInUser = async (data: LoginData): Promise<User> => { const response = await axiosClient.post<Promise<User>>('/login', data); return response.data; }And inside my Login component I have:
const { mutate: loginUser, isLoading } = useMutation( (userData: LoginData) => loggInUser(userData), { onSuccess: (data) => { stateLoggIn(data); }, onError(error: any) { setErrorMsg((error.response && error.response.data && error.response.data.message) || error.message || error.toString()); } } );When the axios promise returns error, for instance 400, I am shown a react native warning for uncatched error. I tried to implement tryCatch inside axios function but then my onError case inside mutation wont ever fire off.
This is the react native expo warning







