Leveraging __typename for login API response
This commit is contained in:
parent
61154028a3
commit
c5308eb430
@ -22,12 +22,11 @@ const LoginPage = () => {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!loginMutation.data) return;
|
||||
if (Object.hasOwn(loginMutation.data.login, "message")) {
|
||||
setSubmitError(loginMutation.data.login.message);
|
||||
if (!loginMutation.data) {
|
||||
return;
|
||||
}
|
||||
if (Object.hasOwn(loginMutation.data.login, "token")) {
|
||||
} else if (loginMutation.data.login.__typename == "CommonError") {
|
||||
setSubmitError(loginMutation.data.login.message);
|
||||
} else if (loginMutation.data.login.__typename == "AuthSuccess") {
|
||||
localStorage.setItem("token", loginMutation.data.login.token);
|
||||
navigator("/services");
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
mutation Login($credentials: LoginInput!) {
|
||||
login(body: $credentials) {
|
||||
__typename
|
||||
... on AuthSuccess {
|
||||
user {
|
||||
name
|
||||
|
Loading…
x
Reference in New Issue
Block a user