mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 14:17:13 +01:00
Updated api fetch to return an object.
This commit is contained in:
parent
e64b35f701
commit
e5cd162b83
10 changed files with 28 additions and 28 deletions
|
|
@ -31,19 +31,19 @@ export default function LoginForm() {
|
|||
const [message, setMessage] = useState();
|
||||
|
||||
const handleSubmit = async ({ username, password }) => {
|
||||
const response = await post('/api/auth/login', { username, password });
|
||||
const { ok, status, data } = await post('/api/auth/login', { username, password });
|
||||
|
||||
if (typeof response !== 'string') {
|
||||
if (ok) {
|
||||
await Router.push('/');
|
||||
} else {
|
||||
setMessage(
|
||||
response.startsWith('401') ? (
|
||||
status === 401 ? (
|
||||
<FormattedMessage
|
||||
id="message.incorrect-username-password"
|
||||
defaultMessage="Incorrect username/password."
|
||||
/>
|
||||
) : (
|
||||
response
|
||||
data
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue