diff --git a/backend/src/article/articleController.js b/backend/src/article/articleController.js index 48ba723e5e6e0e166468a3eafab01a8379eaf831..a445fc9d211b8464ce1eeba8408c68849faebe9d 100644 --- a/backend/src/article/articleController.js +++ b/backend/src/article/articleController.js @@ -86,7 +86,7 @@ router.get("/:id", async (req, res) => { res.send(JSON.stringify(articles)); }); -router.post("/comment/:id", async (req, res) => { +router.post("/:id/comment", async (req, res) => { if (!req.session.sessionid) { console.log("No session"); } @@ -99,7 +99,7 @@ router.post("/comment/:id", async (req, res) => { res.send(JSON.stringify(articles)); }) -router.delete("/comment/:articleid/:commentid", async (req, res) => { +router.delete("/:articleid/comment/:commentid", async (req, res) => { if (!req.session.sessionid) { console.log("No session"); } @@ -107,7 +107,7 @@ router.delete("/comment/:articleid/:commentid", async (req, res) => { res.send(JSON.stringify(articles)); }); -router.put("/comment/like/:id", async (req, res) => { +router.put("/:id/comment/like", async (req, res) => { if (!req.session.sessionid) { console.log("No session"); } diff --git a/frontend/src/components/Comment.js b/frontend/src/components/Comment.js index f200396a9a6573550864b9b2a1c0b60eed3f25fa..d002ab71881a8fe4f48ecac97f5bd69d209c9514 100644 --- a/frontend/src/components/Comment.js +++ b/frontend/src/components/Comment.js @@ -24,7 +24,7 @@ function Comments({data}) { function DeleteComment(e) { const data = {id: _id} axios - .delete(`http://localhost:8080/article/comment/${params.id}/${_id}`, data, + .delete(`http://localhost:8080/article/${params.id}/comment/${_id}`, data, { headers: {"Content-Type": 'application/json'} }) diff --git a/frontend/src/pages/PostRead.js b/frontend/src/pages/PostRead.js index 2c48018b944bbf8cbf25f1b5fa00d6b0eba50b41..3bbad99491fc500ab9b926fb8acbb790d9ce3cd3 100644 --- a/frontend/src/pages/PostRead.js +++ b/frontend/src/pages/PostRead.js @@ -44,7 +44,7 @@ function PostRead() { }, []); function SetLike(){ - axios.put(`http://localhost:8080/article/comment/like/${params.id}`) + axios.put(`http://localhost:8080/article/${params.id}/comment/like`) .then(res => { alert("The comment is successfully uploaded"); return requestLoadArticleById(params.id) @@ -69,7 +69,7 @@ function PostRead() { return } const data = {content: inputComment} - axios.post(`http://localhost:8080/article/comment/${params.id}`, data, + axios.post(`http://localhost:8080/article/${params.id}/comment`, data, { headers: {"Content-Type": 'application/json'} })