export const fetchAds = async () => {
  const response = await fetch('http://localhost:5000/ads');
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  return response.json();
};

export const addAd = async (ad) => {
  const response = await fetch('http://localhost:5000/ads', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(ad),
  });
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  return response.json();
};