JJuOn

Fix api/challenge/list to use parameter instead of query string

...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
20 "goalPerSession":Number 20 "goalPerSession":Number
21 } 21 }
22 ``` 22 ```
23 -1. GET /api/challenge/list?status 23 +1. GET /api/challenge/list/:status
24 - 챌린지 목록 조회 24 - 챌린지 목록 조회
25 -- input(query) 25 +- input(parameter)
26 ``` 26 ```
27 status=(one of ["all","enrolled","progress","end"]) 27 status=(one of ["all","enrolled","progress","end"])
28 ``` 28 ```
......
...@@ -129,12 +129,12 @@ exports.addChallenge = async (ctx) => { ...@@ -129,12 +129,12 @@ exports.addChallenge = async (ctx) => {
129 }; 129 };
130 130
131 131
132 -/* GET /api/challenge/list?status 132 +/* GET /api/challenge/list/:status
133 -query string status can be in ['all','enrolled','progress','end'] 133 +parameter status can be in ['all','enrolled','progress','end']
134 */ 134 */
135 exports.list = async (ctx) => { 135 exports.list = async (ctx) => {
136 try{ 136 try{
137 - const status = ctx.query.status; 137 + const status = ctx.params.status;
138 if (status!=='all'){ 138 if (status!=='all'){
139 const challenges = await Challenge.find({status:status}).select('-_id'); 139 const challenges = await Challenge.find({status:status}).select('-_id');
140 ctx.body = challenges; 140 ctx.body = challenges;
......
...@@ -4,7 +4,7 @@ const challengeCtrl = require('./challege.ctrl'); ...@@ -4,7 +4,7 @@ const challengeCtrl = require('./challege.ctrl');
4 4
5 challenge.post("/getchallenge",challengeCtrl.getChallenge); 5 challenge.post("/getchallenge",challengeCtrl.getChallenge);
6 challenge.post("/addchallenge",challengeCtrl.addChallenge); 6 challenge.post("/addchallenge",challengeCtrl.addChallenge);
7 -challenge.get("/list",challengeCtrl.list); 7 +challenge.get("/list/:status",challengeCtrl.list);
8 challenge.post("/participate",challengeCtrl.participate); 8 challenge.post("/participate",challengeCtrl.participate);
9 9
10 module.exports = challenge; 10 module.exports = challenge;
...\ No newline at end of file ...\ No newline at end of file
......