import { useCallback } from "react";
import useHttpRequest from "../../../hooks/useHttpRequest";
import { get } from "../../../utils/axios";

const cdn = process.env.REACT_APP_CDN_URL;
const endpoints = {
  ping: `${cdn}/health/ping`
};

const useServerApi = () => {
  const { exec } = useHttpRequest();

  const checkHealth = useCallback(
    (options) => {
      const promise = exec(() => get(endpoints.ping), options);
      return promise;
    },
    [exec]
  );

  return {
    checkHealth
  };
};

export default useServerApi;
