From d5643baf50a3e8a99d545e3e08a06872a3cfb4cc Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 15 Jun 2020 17:39:32 +0300 Subject: fix: parse response correctly --- src/index.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index f28aff8..4e2a0b7 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -58,13 +58,12 @@ const App: React.FC = () => { name, password }).then(response => { - const user = response.data.undefined; // TODO: rename 'undefined' field - const { accessToken } = response.data; - - setUser(user); - localStorage.setItem('userId', user._id); - localStorage.setItem('token', accessToken); - navigate('profile', user._id); + const me = response.data.user; + const token = response.data.accessToken; + setUser(me); + localStorage.setItem('userId', me._id); + localStorage.setItem('token', token); + navigate('profile', me._id); return true; }).catch(error => false); }; -- cgit v1.2.3