summaryrefslogtreecommitdiffhomepage
path: root/frontend/src/pages/articles/Article.tsx
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2024-07-27 16:44:01 -0400
committerrealtradam <[email protected]>2024-07-27 16:44:01 -0400
commitf75c5d9264d71298711321d83a9c6b23327b3f56 (patch)
treeb7f964a1e37cdead6a198e1138cc1f06331b0eb5 /frontend/src/pages/articles/Article.tsx
parentb1112afc5162bb299d528974594dcf7c2ec46266 (diff)
downloadspring-blog-f75c5d9264d71298711321d83a9c6b23327b3f56.tar.gz
spring-blog-f75c5d9264d71298711321d83a9c6b23327b3f56.zip
fix linting
Diffstat (limited to 'frontend/src/pages/articles/Article.tsx')
-rw-r--r--frontend/src/pages/articles/Article.tsx46
1 files changed, 28 insertions, 18 deletions
diff --git a/frontend/src/pages/articles/Article.tsx b/frontend/src/pages/articles/Article.tsx
index b367811..1a96ada 100644
--- a/frontend/src/pages/articles/Article.tsx
+++ b/frontend/src/pages/articles/Article.tsx
@@ -1,25 +1,35 @@
import { useState, useEffect } from "react";
import { useParams } from "react-router-dom";
-export default function Article () {
- const { id } = useParams();
- const [articleData, setArticleData] = useState<any>();
+type article = {
+ id: number;
+ title: string;
+ photoUrl: string;
+ content: string;
+ createdOn: string;
+ updateOn: string;
+};
- useEffect(() => {
- const url = `${import.meta.env.VITE_API_TITLE}/api/v1/article/${id}`;
- fetch(url).then((response) => {
- if (response.ok) {
- return response.json();
- }
- throw new Error("Network response was not ok.");
- }).then((response) => setArticleData(response)); //.catch(() => navigate("/"));
- }, [id]);
+export default function Article() {
+ const { id } = useParams();
+ const [articleData, setArticleData] = useState<article>();
- return(
- <>
- <h1>{articleData?.title}</h1>
- <div>{articleData?.content}</div>
- </>
- );
+ useEffect(() => {
+ const url = `${import.meta.env.VITE_API_TITLE}/api/v1/article/${id}`;
+ fetch(url)
+ .then((response) => {
+ if (response.ok) {
+ return response.json();
+ }
+ throw new Error("Network response was not ok.");
+ })
+ .then((response) => setArticleData(response)); //.catch(() => navigate("/"));
+ }, [id]);
+ return (
+ <>
+ <h1>{articleData?.title}</h1>
+ <div>{articleData?.content}</div>
+ </>
+ );
}