From 5ff79ac13ac78c92dc74809fe9a5c7b16dafc574 Mon Sep 17 00:00:00 2001 From: IsthisLee Date: Fri, 10 Dec 2021 13:06:21 +0900 Subject: [PATCH] =?UTF-8?q?circles=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 2 +- routers/circles.js | 28 ++++++++++++---------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/app.js b/app.js index 2314de1..7cf8490 100644 --- a/app.js +++ b/app.js @@ -8,7 +8,7 @@ const corsOptions = { origin: "", }; -app.use(cors(corsOptions)); +app.use(cors()); const connect = require("./models"); connect(); diff --git a/routers/circles.js b/routers/circles.js index 83ae4ef..aba9477 100644 --- a/routers/circles.js +++ b/routers/circles.js @@ -5,7 +5,7 @@ const auth = require("../middlewares/auth"); router .route("/circles/:circles_id/feedback") - .get( async (req, res) => { + .get(async (req, res) => { const { circles_id } = req.params; // circles_id => unique; try { @@ -19,13 +19,12 @@ router } catch (error) { console.log(error); } - }) - .post( async (req, res) => { + .post(async (req, res) => { const { projects_id, circles_id, feedback } = req.body; - + try { - if(feedback==""){ + if (feedback == "") { res.status(400).send({ errorMessage: "피드백을 입력해주세요!", }); @@ -43,18 +42,17 @@ router } const returnData = await circles.findOne({ circles_id }); res.status(200).send(returnData); - } catch(error) { + } catch (error) { res.status(400).send({ errorMessage: "피드백 등록에 실패하였습니다!", }); } - }) - .put( async (req, res) => { + .put(async (req, res) => { const { circles_id, feedback } = req.body; - try{ - if(feedback==""){ + try { + if (feedback == "") { res.status(400).send({ errorMessage: "피드백을 입력해주세요!", }); @@ -72,15 +70,14 @@ router } const returnData = await circles.findOne({ circles_id }); res.status(200).send(returnData); - } catch(error) { + } catch (error) { res.status(400).send({ errorMessage: "피드백 수정에 실패하였습니다!", }); } - }) - .delete( async (req, res) => { - const { circles_id } = req.body; + .delete(async (req, res) => { + const { circles_id } = req.params; try { const successCount = await circles.updateOne( @@ -95,12 +92,11 @@ router } const returnData = await circles.findOne({ circles_id }); res.status(200).send(returnData); - } catch(error) { + } catch (error) { res.status(400).send({ errorMessage: "피드백 삭제에 실패하였습니다!", }); } - }); // 인증 api