fix feedback receiving function

This commit is contained in:
adueck 2022-10-11 14:59:00 +05:00
parent 271c2a88ab
commit a8848b414a
2 changed files with 12 additions and 15 deletions

View File

@ -15,14 +15,18 @@ const feedbackRouter = express.Router();
* receives a piece of feedback
*/
feedbackRouter.put("/", (req, res, next) => {
if (!req.user) {
addFeedback({
user: req.user,
feedback: req.body,
});
}
// @ts-ignore;
sendResponse(res, { ok: true, message: "feedback received" });
const feedback = { user: req.user, feedback: req.body };
addFeedback({
user: req.user,
feedback: req.body,
}).then(() => {
res.send({ ok: true, message: "feedback received" });
}).catch((e) => {
console.error("error receiving feedback");
console.error("feedback missed", feedback);
console.error(e);
next("error receiving feedback");
});
});
export default feedbackRouter;

View File

@ -1,7 +0,0 @@
POST https://account.lingdocs.com/feedback HTTP/1.1
content-type: application/json
{
"value": 4,
"feedback": "This is really great"
}