🥅 Handle AxiosErrors in Login page (#1162)
This commit is contained in:
@@ -2,6 +2,7 @@ import { useMutation, useQuery } from "@tanstack/react-query"
|
||||
import { useNavigate } from "@tanstack/react-router"
|
||||
import { useState } from "react"
|
||||
|
||||
import { AxiosError } from "axios"
|
||||
import {
|
||||
type Body_login_login_access_token as AccessToken,
|
||||
type ApiError,
|
||||
@@ -36,7 +37,12 @@ const useAuth = () => {
|
||||
navigate({ to: "/" })
|
||||
},
|
||||
onError: (err: ApiError) => {
|
||||
const errDetail = (err.body as any)?.detail
|
||||
let errDetail = (err.body as any)?.detail
|
||||
|
||||
if (err instanceof AxiosError) {
|
||||
errDetail = err.message
|
||||
}
|
||||
|
||||
setError(errDetail)
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user