export const apiGetUserSearch = async ({
  page,
  search,
}: {
  page: string;
  search: string;
}) => {
  const { token } = await fetch("/api/get-cookie").then((res) => res.json());
  if (!token) return await token.json().catch(() => null);

  const isPage = page ? `?page=${page}` : "";
  const isSearch = search ? `&search=${search}` : "";

  const response = await fetch(`/api/user${isPage}${isSearch}`, {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
      Accept: "application/json",
      Authorization: `Bearer ${token}`,
    },
  });

  return await response.json().catch(() => null);
};
