diff --git a/src/components/Login/email-login-form.tsx b/src/components/Login/EmailLoginForm.tsx similarity index 81% rename from src/components/Login/email-login-form.tsx rename to src/components/Login/EmailLoginForm.tsx index 0b0fc5138..d8321b7a5 100644 --- a/src/components/Login/email-login-form.tsx +++ b/src/components/Login/EmailLoginForm.tsx @@ -24,18 +24,25 @@ const EmailLoginForm: FunctionComponent<{}> = () => { body: JSON.stringify({ email, password, - // name: 'Arikko', }), - }).then(async (res) => { - const json = await res.json(); - if (res.status === 200) { - Cookies.set(TOKEN_COOKIE_NAME, json.token); - window.location.href = '/'; - } else { - console.log('error', json); - setError(json); - } - }); + }) + .then(async (res) => { + const json = await res.json(); + if (res.status === 200) { + Cookies.set(TOKEN_COOKIE_NAME, json.token); + window.location.href = '/'; + } else { + const error = new Error(json.message) as any; + error.status = res.status; + throw error; + } + }) + .catch((err) => { + setError({ + message: err.message, + status: 400, + }); + }); }} >