import useSWR from "swr";
import qs from "qs";
import { get } from "../http";

function useGet<T = any, E = any>(api: string, query?: unknown) {
  let url = api;
  if (query) url += "?" + qs.stringify(query);
  return useSWR<ResData<T>, E>(url, get, {
    // revalidateOnMount: false,
    revalidateOnFocus: false,
    revalidateIfStale: false,
    revalidateOnReconnect: false,
  });
}

export default useGet;
