From 512b61c2a4ee89918cbb1fd2ded6c5ff771cf0f5 Mon Sep 17 00:00:00 2001 From: Alex Muszynski Date: Fri, 4 Jul 2025 10:24:43 -0400 Subject: [PATCH] fix: fetch was not using rest requests --- frontend/src/App.tsx | 7 ++++++- frontend/src/utils/BlogList.tsx | 7 ++++++- frontend/src/utils/BlogViewer.tsx | 7 ++++++- frontend/src/utils/EditBlog.tsx | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 210dbcb..d6d847c 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -83,7 +83,12 @@ function BlogPage() { const [blogs, setBlogs] = useState([]); useEffect(() => { - fetch(`${API_URL}/blogs`) + fetch(`${API_URL}/blogs`, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }) .then((res) => res.json()) .then((data: Blog[]) => setBlogs(data)) .catch((err) => console.error(err)); diff --git a/frontend/src/utils/BlogList.tsx b/frontend/src/utils/BlogList.tsx index 29c30b7..0f52c41 100644 --- a/frontend/src/utils/BlogList.tsx +++ b/frontend/src/utils/BlogList.tsx @@ -4,7 +4,12 @@ import { API_URL } from "./constants"; export function BlogList() { const [content, setContent] = useState(""); useEffect(() => { - fetch(`${API_URL}/get-blogs`) + fetch(`${API_URL}/get-blogs`, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }) .then((res) => res.text()) .then(setContent); }, []); diff --git a/frontend/src/utils/BlogViewer.tsx b/frontend/src/utils/BlogViewer.tsx index e9537be..b1432cd 100644 --- a/frontend/src/utils/BlogViewer.tsx +++ b/frontend/src/utils/BlogViewer.tsx @@ -16,7 +16,12 @@ export function BlogViewer() { useEffect(() => { if (!slug) return; - fetch(`${API_URL}/blogs/${slug}`) + fetch(`${API_URL}/blogs/${slug}`, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }) .then((res) => res.json()) .then((data: Blog) => setBlog(data)) .catch((err) => console.error(err)); diff --git a/frontend/src/utils/EditBlog.tsx b/frontend/src/utils/EditBlog.tsx index bd2231e..647d4b2 100644 --- a/frontend/src/utils/EditBlog.tsx +++ b/frontend/src/utils/EditBlog.tsx @@ -16,7 +16,12 @@ export function EditBlog() { useEffect(() => { if (!slug) return; - fetch(`${API_URL}/blogs/${slug}`) + fetch(`${API_URL}/blogs/${slug}`, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }) .then((res) => res.json()) .then((data: Blog) => { setBlog(data);