Skip to content

Commit

Permalink
hande register error
Browse files Browse the repository at this point in the history
  • Loading branch information
OddyHater committed Sep 12, 2023
1 parent e1925ba commit 6fb36cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions frontend/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,25 @@ function App() {
}, [loggedIn]);

useEffect(() => {
AppApi.getProfileInfo()
const token = localStorage.getItem('token');
if(token) {
AppApi.getProfileInfo()
.then((res) => {
setCurrentUser(res.user);
})
.catch((err) => console.log(err));
}
}, [loggedIn]);

useEffect(() => {
AppApi.getInitialCards()
const token = localStorage.getItem('token');
if(token) {
AppApi.getInitialCards()
.then((res) => {
setCards(res.data);
})
.catch((err) => console.log(err));
}
}, [loggedIn]);


Expand Down Expand Up @@ -171,7 +177,8 @@ function App() {
}
})
.catch((err) => {
console.log(err);
setInfoTitle('Что-то пошло не так! Попробуйте ещё раз.');
setInfoImageStatus(false);
})
.finally(() => {
setIsInfoPopupOpen(true);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Auth {
})
.then(res => {
return this._getResponseData(res);
})
});
}

login({email, password}) {
Expand All @@ -46,7 +46,7 @@ class Auth {
})
.then(res => {
return this._getResponseData(res);
})
});
}
}

Expand Down

0 comments on commit 6fb36cf

Please sign in to comment.