diff options
| author | realtradam <[email protected]> | 2024-07-27 02:00:57 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2024-07-27 02:00:57 -0400 |
| commit | de3d80ce3ea20a869d700c3238020d44059de099 (patch) | |
| tree | ef849326ea4922530990d5dc29cb8ff3532e82fe /frontend/src/pages/articles/Article.tsx | |
| parent | 6b342f97f6a605b7e1fe34584abbbf962ca39b7c (diff) | |
| download | spring-blog-de3d80ce3ea20a869d700c3238020d44059de099.tar.gz spring-blog-de3d80ce3ea20a869d700c3238020d44059de099.zip | |
working login and auth
Diffstat (limited to 'frontend/src/pages/articles/Article.tsx')
| -rw-r--r-- | frontend/src/pages/articles/Article.tsx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/frontend/src/pages/articles/Article.tsx b/frontend/src/pages/articles/Article.tsx new file mode 100644 index 0000000..b367811 --- /dev/null +++ b/frontend/src/pages/articles/Article.tsx @@ -0,0 +1,25 @@ +import { useState, useEffect } from "react"; +import { useParams } from "react-router-dom"; + +export default function Article () { + const { id } = useParams(); + const [articleData, setArticleData] = useState<any>(); + + 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> + </> + ); + +} |
