djledda.de main
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 2 месеци
1234567891011121314
  1. export type DJAPIEndpoint = "/rp-articles";
  2. export interface DJAPIResultMap extends Record<DJAPIEndpoint, unknown> {
  3. "/rp-articles": { slug: string; name: string }[];
  4. }
  5. export type DJAPIResult = DJAPIResultMap[DJAPIEndpoint];
  6. export default async function getDJAPI<T extends DJAPIEndpoint>(
  7. hostUrl: string,
  8. endpoint: T,
  9. ): Promise<DJAPIResultMap[typeof endpoint]> {
  10. return await (await fetch(`${hostUrl}/api${endpoint}`)).json();
  11. }