This commit is contained in:
Janis
2023-02-05 19:58:46 +01:00
parent 8b8d75ca65
commit d41c8be336
25 changed files with 447 additions and 93 deletions

View File

@@ -18,6 +18,7 @@ export class FetchManager {
static Article = class {
static async list(noCache: boolean = false): Promise<ArticleWithIncludes[]> {
console.log(urlJoin(apiUrl, `articles`))
const response = await fetch(urlJoin(apiUrl, `articles`), {
cache: GLOBAL_NO_CACHE || noCache ? "no-cache" : "force-cache",
next: { revalidate: 60 * 10 },
@@ -26,6 +27,7 @@ export class FetchManager {
}
static async get(id: string, noCache: boolean = false): Promise<ArticleWithIncludes> {
urlJoin(apiUrl, `articles/${id}`)
const response = await fetch(urlJoin(apiUrl, `articles/${id}`), {
cache: GLOBAL_NO_CACHE || noCache ? "no-cache" : "force-cache",
next: { revalidate: 60 * 10 },
@@ -42,6 +44,15 @@ export class FetchManager {
})
return await response.json()
}
static async getByCategory(name: string, noCache: boolean = false): Promise<ArticleWithIncludes[]> {
const response = await fetch(urlJoin(apiUrl, `articles?categoryName=${name}`), {
cache: GLOBAL_NO_CACHE || noCache ? "no-cache" : "force-cache",
next: { revalidate: 60 * 10 },
})
return await response.json()
}
}