/**
 * Utility function to fetch data from the WordPress REST API.
 */

const fetchUserData = async (query, value) => {
	const baseUrl = `${window.location.protocol}//${window.location.host}/wp-json/`;

	try {
		const response = await fetch(`${baseUrl}${query}${value}`);
		return await response.json();
	} catch (error) {
		console.error('API fetch error:', error);
		return null;
	}
};

export default fetchUserData;
