import {queryOptions} from "@tanstack/react-query";
import axios from "axios";

export function getServers(token: string) {
    return queryOptions({
        queryKey: ["servers"],
        queryFn: () => fetchSettings(token),
        enabled: !!token,
        staleTime: 1000,
        refetchInterval: 2500,
        refetchOnWindowFocus: true,
    });
}

const fetchSettings = async (token: string) => {
    const {data} = await axios.get("/api/server/servers", {headers: {Authorization: `Bearer ${token}`}});

    return data.data;
};
