big updats
This commit is contained in:
22
app/api.ts
22
app/api.ts
@@ -1,23 +1,23 @@
|
||||
export type DJAPIEndpoint = "/rp-articles";
|
||||
export type DjAPIEndpoint = "/rp-articles";
|
||||
|
||||
type RPArticle = {
|
||||
title: string,
|
||||
slug: string;
|
||||
titleDe: string,
|
||||
titleEn: string,
|
||||
author: string,
|
||||
type RPArticle = {
|
||||
title: string,
|
||||
slug: string;
|
||||
titleDe: string,
|
||||
titleEn: string,
|
||||
author: string,
|
||||
tags?: string[],
|
||||
};
|
||||
|
||||
export interface DJAPIResultMap extends Record<DJAPIEndpoint, unknown> {
|
||||
export interface DjAPIResultMap extends Record<DjAPIEndpoint, unknown> {
|
||||
"/rp-articles": RPArticle[];
|
||||
}
|
||||
|
||||
export type DJAPIResult = DJAPIResultMap[DJAPIEndpoint];
|
||||
export type DjAPIResult = DjAPIResultMap[DjAPIEndpoint];
|
||||
|
||||
export default async function getDJAPI<T extends DJAPIEndpoint>(
|
||||
export default async function getDjAPI<T extends DjAPIEndpoint>(
|
||||
hostUrl: string,
|
||||
endpoint: T,
|
||||
): Promise<DJAPIResultMap[typeof endpoint]> {
|
||||
): Promise<DjAPIResultMap[typeof endpoint]> {
|
||||
return await (await fetch(`${hostUrl}/api${endpoint}`)).json();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user