diff --git a/client-solid/src/Util/api.ts b/client-solid/src/Util/api.ts index ff0a77a..8cbd464 100644 --- a/client-solid/src/Util/api.ts +++ b/client-solid/src/Util/api.ts @@ -46,19 +46,20 @@ export interface PublicComment { } export async function getPosts(): Promise { - const res = await fetch("/api/posts"); + const res = await fetch("/api/posts", { cache: "no-cache" }); const data = await res.json(); return data; } export async function getPost(id: string): Promise { - const res = await fetch(`/api/posts/${id}`); + const res = await fetch(`/api/posts/${id}`, { cache: "no-cache" }); const data = await res.json(); return data; } export async function createPost(post: NewPost): Promise { await fetch("/api/posts", { + cache: "no-cache", method: "POST", headers: { "Content-Type": "application/json", @@ -69,6 +70,7 @@ export async function createPost(post: NewPost): Promise { export async function createComment(comment: NewComment): Promise { await fetch("/api/comments", { + cache: "no-cache", method: "POST", headers: { "Content-Type": "application/json", @@ -84,13 +86,16 @@ export async function getComments( offset: number ): Promise { const res = await fetch( - `/api/comments?post_id=${postId}&limit=${limit}&offset=${offset}` + `/api/comments?post_id=${postId}&limit=${limit}&offset=${offset}`, + { + cache: "no-cache", + } ); const data = await res.json(); return data; } -/** +/** * Gets the Engagement counts for a post by postId * @param postId The id of the post * @returns {Promise} A promise that contains number of post engages @@ -103,6 +108,7 @@ export async function getEngagementCount(postId: string): Promise { export async function deletePost(id: string, token: string): Promise { return await fetch(`/api/posts/${id}`, { + cache: "no-cache", method: "DELETE", headers: { "Content-Type": "application/json", @@ -118,6 +124,7 @@ export async function submitRegistration( captcha: string ): Promise { const response = await fetch("/api/register", { + cache: "no-cache", method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password, captcha }), @@ -133,6 +140,7 @@ export async function submitLogin( ): Promise { if (username == "" || password == "") return; const response = await fetch("/api/login", { + cache: "no-cache", method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password }), @@ -148,6 +156,7 @@ export async function submitLogin( */ export async function engage(postId: string, token: string): Promise { return await fetch(`/api/posts/${postId}/engage`, { + cache: "no-cache", method: "POST", headers: { "Content-Type": "application/json",