mirror of
https://github.com/DerTyp7/explainegy-nextjs.git
synced 2025-10-29 21:02:13 +01:00
sdf
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user