JJuOn

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

......@@ -20,9 +20,9 @@
"goalPerSession":Number
}
```
1. GET /api/challenge/list?status
1. GET /api/challenge/list/:status
- 챌린지 목록 조회
- input(query)
- input(parameter)
```
status=(one of ["all","enrolled","progress","end"])
```
......
......@@ -129,12 +129,12 @@ exports.addChallenge = async (ctx) => {
};
/* GET /api/challenge/list?status
query string status can be in ['all','enrolled','progress','end']
/* GET /api/challenge/list/:status
parameter status can be in ['all','enrolled','progress','end']
*/
exports.list = async (ctx) => {
try{
const status = ctx.query.status;
const status = ctx.params.status;
if (status!=='all'){
const challenges = await Challenge.find({status:status}).select('-_id');
ctx.body = challenges;
......
......@@ -4,7 +4,7 @@ const challengeCtrl = require('./challege.ctrl');
challenge.post("/getchallenge",challengeCtrl.getChallenge);
challenge.post("/addchallenge",challengeCtrl.addChallenge);
challenge.get("/list",challengeCtrl.list);
challenge.get("/list/:status",challengeCtrl.list);
challenge.post("/participate",challengeCtrl.participate);
module.exports = challenge;
\ No newline at end of file
......