mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-10 05:15:35 +08:00
refactor: shorten checkEndpoint
This commit is contained in:
parent
0e54e396d1
commit
1cffb4b305
@ -21,27 +21,17 @@ export default () => {
|
||||
navigate('/overview')
|
||||
}
|
||||
|
||||
const checkEndpoint = async ({
|
||||
url,
|
||||
secret,
|
||||
}: {
|
||||
url: string
|
||||
secret: string
|
||||
}) => {
|
||||
try {
|
||||
const { ok } = await ky.get(url, {
|
||||
const checkEndpoint = ({ url, secret }: { url: string; secret: string }) =>
|
||||
ky
|
||||
.get(url, {
|
||||
headers: secret
|
||||
? {
|
||||
Authorization: `Bearer ${secret}`,
|
||||
}
|
||||
: {},
|
||||
})
|
||||
|
||||
return ok
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
.then(({ ok }) => ok)
|
||||
.catch(() => false)
|
||||
|
||||
const onEndpointSelect = async (id: string) => {
|
||||
const endpoint = endpointList().find((e) => e.id === id)
|
||||
|
Loading…
Reference in New Issue
Block a user