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