export default async function fetchMoreProducts(page) {
  const location = window.location.origin;
  const endpoint = `/wp-json/firevert/v1/power-widget/main/products?page=${page}`;

  const response = await fetch(`${location}${endpoint}`, {
    method: "GET",
    credentials: "same-origin",
    headers: {
      "Content-Type": "application/json",
    },
  });

  const data = await response.json();
  if (!response.ok) throw new Error(data.error);
  if (response.status !== 200) return;

  return data;
}
