Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beasy-mobile
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
G
beasy-mobile
Commits
4a40ec39
Commit
4a40ec39
authored
May 07, 2024
by
G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handling request error a little better by checking if response is inside the error object
parent
216da516
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
UserLoginScreen.tsx
src/screens/UserLoginScreen.tsx
+10
-3
No files found.
src/screens/UserLoginScreen.tsx
View file @
4a40ec39
...
@@ -10,6 +10,7 @@ import Text from "@components/bases/Text";
...
@@ -10,6 +10,7 @@ import Text from "@components/bases/Text";
import
{
Fontisto
}
from
"@expo/vector-icons"
;
import
{
Fontisto
}
from
"@expo/vector-icons"
;
import
{
containers
}
from
"@styles/Commons"
;
import
{
containers
}
from
"@styles/Commons"
;
import
{
useMutation
}
from
"@tanstack/react-query"
;
import
{
useMutation
}
from
"@tanstack/react-query"
;
import
type
{
AxiosError
}
from
"axios"
;
import
{
useCallback
,
useState
}
from
"react"
;
import
{
useCallback
,
useState
}
from
"react"
;
import
{
KeyboardAvoidingView
,
Platform
,
TouchableOpacity
,
View
}
from
"react-native"
;
import
{
KeyboardAvoidingView
,
Platform
,
TouchableOpacity
,
View
}
from
"react-native"
;
import
{
useSafeAreaInsets
}
from
"react-native-safe-area-context"
;
import
{
useSafeAreaInsets
}
from
"react-native-safe-area-context"
;
...
@@ -28,14 +29,20 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
...
@@ -28,14 +29,20 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
mutationFn
:
authenticateUser
,
mutationFn
:
authenticateUser
,
onSuccess
:
(
data
)
=>
{
onSuccess
:
(
data
)
=>
{
setAuthenticationData
(
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
);
console
.
error
(
"error :: "
,
error
.
response
.
data
);
if
(
error
.
response
.
status
===
400
)
{
if
(
error
.
response
.
status
===
400
)
{
return
setError
(
"Bad request"
);
return
setError
(
"Bad request"
);
}
}
setError
(
error
.
response
.
data
.
detail
);
const
message
:
string
=
error
.
response
.
data
.
detail
;
return
setError
(
message
);
}
setError
(
"Unknown error"
);
},
},
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment