export const fetchWordpressPosts = async ( path: string, normalizer: any, count: string = "6" ) => { const res = await fetch(`${path}?maxResults=${count}`); if (res.status !== 200) { console.error("Failed to fetch posts", res); return null; } const json = await res.json(); return json.posts.map(normalizer); }; export const fetchSingleWordpressPost = async ( path: string, id: string, normalizer: any ) => { const res = await fetch(`${path}/${id}`); if (res.status !== 200) { console.error(`Failed to fetch post with id: ${id}`, res); return null; } const json = await res.json(); return normalizer(json); };