You need to sign in or sign up before continuing.
Commit 4a40ec39 by G

handling request error a little better by checking if response is inside the error object

parent 216da516
......@@ -10,6 +10,7 @@ import Text from "@components/bases/Text";
import { Fontisto } from "@expo/vector-icons";
import { containers } from "@styles/Commons";
import { useMutation } from "@tanstack/react-query";
import type { AxiosError } from "axios";
import { useCallback, useState } from "react";
import { KeyboardAvoidingView, Platform, TouchableOpacity, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
......@@ -28,14 +29,20 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
mutationFn: authenticateUser,
onSuccess: (data) => {
setAuthenticationData(data);
navigation.navigate("bottomTabs");
navigation.popToTop();
navigation.replace("bottomTabs");
},
onError: (error) => {
// biome-ignore lint/suspicious/noExplicitAny: <Axios error>
onError: (error: AxiosError<any>) => {
if (error.response) {
console.error("error :: ", error.response.data);
if (error.response.status === 400) {
return setError("Bad request");
}
setError(error.response.data.detail);
const message: string = error.response.data.detail;
return setError(message);
}
setError("Unknown error");
},
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment