improve typing and responses
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user