/**
 * Custom hook function to fetch data using Rest API.
 */

const fetchUserData = async (query, value) => {
	const baseUrl = `${window.location.protocol}//${window.location.host}/wp-json/`;
	let defaultData ;
	try {
		const response = await fetch(`${baseUrl}${query}${value}`);
		const data = await response.json();
		defaultData = data;
	} catch (error) {
		defaultData = "*Error in connecting Data Base !";
	}
	return  defaultData;
}

export default fetchUserData