djledda.de main
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

15 行
452 B

  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. }