diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-15 17:39:32 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-15 17:39:32 +0300 |
commit | d5643baf50a3e8a99d545e3e08a06872a3cfb4cc (patch) | |
tree | 1cb59e408199d4c5df7204d3820e6990a466b939 | |
parent | dd0c6babb832772cb017171476b2629ef00ee147 (diff) | |
download | which-ui-d5643baf50a3e8a99d545e3e08a06872a3cfb4cc.tar.gz |
fix: parse response correctly
-rw-r--r-- | src/index.tsx | 13 |
1 files 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); }; |