Commit 15aed670 authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

0711

parent 65ed18b5
...@@ -6,4 +6,9 @@ export const createSurvey = async (survey:SurveyType) => { ...@@ -6,4 +6,9 @@ export const createSurvey = async (survey:SurveyType) => {
console.log(survey) console.log(survey)
const {data} = await axios.post(`${baseUrl}/surveys/create`, {...survey}) const {data} = await axios.post(`${baseUrl}/surveys/create`, {...survey})
return data; return data;
}
export const getSurvey = async () => {
const {data} = await axios.get(`${baseUrl}/surveys/profile`)
return data;
} }
\ No newline at end of file
...@@ -7,3 +7,8 @@ export const createSurvey = asyncWrap(async (req, res) => { ...@@ -7,3 +7,8 @@ export const createSurvey = asyncWrap(async (req, res) => {
const newSurvey = await surveyDb.createSurvey(survey); const newSurvey = await surveyDb.createSurvey(survey);
return res.json(newSurvey); return res.json(newSurvey);
}); });
export const getSurveys = asyncWrap(async (req, res) => {
const surveys = await surveyDb.getSurveys();
return res.json(surveys);
});
...@@ -4,3 +4,8 @@ export const createSurvey = async (survey: ISurvey) => { ...@@ -4,3 +4,8 @@ export const createSurvey = async (survey: ISurvey) => {
const newSurvey = await Survey.create(survey); const newSurvey = await Survey.create(survey);
return newSurvey; return newSurvey;
}; };
export const getSurveys = async () => {
const surveys = await Survey.find({}).populate("questions")
return surveys
}
\ No newline at end of file
...@@ -6,5 +6,8 @@ const router = express.Router(); ...@@ -6,5 +6,8 @@ const router = express.Router();
router router
.route("/create") .route("/create")
.post(surveyCtrl.createSurvey); .post(surveyCtrl.createSurvey);
router
.route("/profile")
.get(surveyCtrl.getSurveys)
export default router; export default router;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment