Skip to content

Commit

Permalink
responses fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Chmod351 committed Jun 30, 2023
1 parent 962284c commit 12ae3cc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions server/Responses/responsesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const responseControllers = {
};

function createResponse(req, res, next) {
console.log(req.params.commentId)
console.log(req.params.commentId);
responseService
.createResponse(req.user.id, req.params.id, req.body.description)
.createResponse(req.user.id, req.params.commentId, req.body.description)
.then((response) => res.json(response))
.catch((error) => next(error));
}
Expand All @@ -31,7 +31,7 @@ function hideResponse(req, res, next) {

function getAllResponse(req, res, next) {
responseService
.getAllComments(req.query.page, req.query.size)
.getAllResponse(req.query.page, req.query.size)
.then((response) => res.json(response))
.catch((error) => next(error));
}
Expand Down
2 changes: 1 addition & 1 deletion server/Responses/responsesModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ResponsesSchema = new mongoose.Schema(
},
commentId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Comments',
ref: 'Comment',
required: true,
},
description: {
Expand Down
2 changes: 1 addition & 1 deletion server/Responses/responsesRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ router.post(
);

router.put(
'/delete/:responsesId',
'/hide/:responsesId',
authMiddleware,
responseControllers.hideResponse,
);
Expand Down
6 changes: 2 additions & 4 deletions server/Responses/responsesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const responseService = {
// create response
async function createResponse(userId, description) {
const newResponse = new Response({ description, userId });
const res=await newResponse.save();
const res = await newResponse.save();
return res;
}

Expand All @@ -24,9 +24,7 @@ async function getAllResponse(page, size) {

// delete response
async function deleteResponse(responseId) {
return await Response.findByIdAndDelete(responseId);
return await Response.findByIdAndUpdate(responseId);
}



export default responseService;

0 comments on commit 12ae3cc

Please sign in to comment.