export async function getInfographics(
  limit: number = 12,
  page: number = 1,
  topic: string
) {
  const response = await fetch(
    'https://data.nks.vn/api/nks/sinfos',
    {
      method: 'POST',

      headers: {
        'Content-Type': 'application/json',
      },

      body: JSON.stringify({
        limit: limit,
        page: page,
        slug: topic,
      }),
    }
  );

  if (!response.ok) {
    throw new Error(
      `API Error ${response.status}`
    );
  }

  const result =
    await response.json();

  return result;
}

export async function getInfographic(
  slug: string
) {
  const response = await fetch(
    'https://data.nks.vn/api/nks/sinfo',
    {
      method: 'POST',

      headers: {
        'Content-Type': 'application/json',
      },

      body: JSON.stringify({
        slug: slug
      }),
    }
  );

  if (!response.ok) {
    throw new Error(
      `API Error ${response.status}`
    );
  }

  const result =
    await response.json();


  return result;
}