Skip to content
Snippets Groups Projects
Commit b035424b authored by Gwangbin's avatar Gwangbin
Browse files

WIP: comment methos changing

parent 15db6dcb
No related branches found
No related tags found
No related merge requests found
......@@ -86,4 +86,34 @@ router.get("/:id", async (req, res) => {
res.send(JSON.stringify(articles));
});
router.post("/comment/:id", async (req, res) => {
if (!req.session.sessionid) {
console.log("No session");
}
const user = await userService.findUserByEmail(req.session.sessionid.email);
const data = {
content: req.body.content,
author: user._id
}
const articles = await articleService.createComment(req.params.id, data);
res.send(JSON.stringify(articles));
})
router.delete("/comment/:articleid/:commentid", async (req, res) => {
if (!req.session.sessionid) {
console.log("No session");
}
const articles = await articleService.deleteComment(req.params.articleid, req.params.commentid);
res.send(JSON.stringify(articles));
});
router.put("/comment/like/:id", async (req, res) => {
if (!req.session.sessionid) {
console.log("No session");
}
const user = await userService.findUserByEmail(req.session.sessionid.email);
const articles = await articleService.setLike(req.params.id, user._id)
res.send(JSON.stringify(articles));
});
export default router;
......@@ -24,7 +24,7 @@ function Comments({data}) {
function DeleteComment(e) {
const data = {id: _id}
axios
.delete(`http://localhost:8080/post/comment/${params.id}/${_id}`, data,
.delete(`http://localhost:8080/article/comment/${params.id}/${_id}`, data,
{
headers: {"Content-Type": 'application/json'}
})
......
......@@ -44,7 +44,7 @@ function PostRead() {
}, []);
function SetLike(){
axios.put(`http://localhost:8080/post/comment/like/${params.id}`)
axios.put(`http://localhost:8080/article/comment/like/${params.id}`)
.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/post/comment/${params.id}`, data,
axios.post(`http://localhost:8080/article/comment/${params.id}`, data,
{
headers: {"Content-Type": 'application/json'}
})
......@@ -124,7 +124,7 @@ function PostRead() {
async function requestLoadArticleById(id) {
const response = await axios({
url: `http://localhost:8080/post/article/${id}`, // 통신할 웹문서
url: `http://localhost:8080/article/${id}`, // 통신할 웹문서
method: 'get', // 통신할 방식
});
return response;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment