mirror of
https://github.com/logos-storage/logos-storage-marketplace-ui.git
synced 2026-01-04 06:23:08 +00:00
Extract port forwarding to external file
This commit is contained in:
parent
92a7dde971
commit
f5de413cf2
@ -1,4 +1,5 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Echo } from "../utils/echo";
|
||||
import { Errors } from "../utils/errors";
|
||||
|
||||
type PortForwardingResponse = { reachable: boolean };
|
||||
@ -6,9 +7,7 @@ type PortForwardingResponse = { reachable: boolean };
|
||||
export function usePortForwarding(online: boolean) {
|
||||
const { data, isFetching, refetch } = useQuery({
|
||||
queryFn: (): Promise<PortForwardingResponse> =>
|
||||
fetch(import.meta.env.VITE_ECHO_URL + "/port/8070")
|
||||
.then((res) => res.json())
|
||||
.catch((e) => Errors.report(e)),
|
||||
Echo.portForwarding().catch((e) => Errors.report(e)),
|
||||
queryKey: ["port-forwarding"],
|
||||
|
||||
initialData: { reachable: false },
|
||||
|
||||
5
src/utils/echo.ts
Normal file
5
src/utils/echo.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export const Echo = {
|
||||
portForwarding: () => fetch(import.meta.env.VITE_ECHO_URL + "/port/8070")
|
||||
.then((res) => res.json())
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user