export const fetchData = async (url, nonce) => {
try {
const response = await fetch(url, {
method: 'GET',
headers: {
'X-WP-Nonce': nonce,
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error("Error:", error);
throw error;
}
};