export type DjAPIEndpoint = | "/rp-articles" | "/blog-entries" ; type BlogEntry = { title: string, slug: string; createdAt: string, updatedAt: string, tags?: string[], guid: string, teaser: string, }; type RPArticle = { title: string, slug: string; titleDe: string, titleEn: string, author: string, tags?: string[], }; export interface DjAPIResultMap extends Record { "/rp-articles": RPArticle[]; "/blog-entries": BlogEntry[]; } export type DjAPIResult = DjAPIResultMap[DjAPIEndpoint]; export default async function getDjAPI( hostUrl: string, endpoint: T, ): Promise { return await (await fetch(`${hostUrl}/api${endpoint}`)).json(); }