improve typing and responses

This commit is contained in:
João Geonizeli
2022-07-10 15:13:40 -03:00
parent e3729ae4c0
commit acaba0f9ca
10 changed files with 289 additions and 248 deletions

View File

@@ -31,8 +31,8 @@ export const NewAccount = () => {
})
.then(async (res) => {
const result = await res.json();
if (result.error) {
setError(result.error);
if (result.errors) {
setError(result.errors[0]);
} else {
login(data.email, data.password);
}

View File

@@ -47,7 +47,7 @@ export const AuthProvider = ({ children, ...rest }: AuthProviderProps) => {
}),
}).then(async (res) => {
if (res.status === 200) {
setToken((await res.json()).token);
setToken((await res.json()).data.token);
setIsLoginDialogOpen(false);
}
});