Showing
1 changed file
with
24 additions
and
19 deletions
| ... | @@ -34,42 +34,47 @@ app.post('/message', function(req,res){ | ... | @@ -34,42 +34,47 @@ app.post('/message', function(req,res){ |
| 34 | 34 | ||
| 35 | var send = {}; | 35 | var send = {}; |
| 36 | function delay(){ | 36 | function delay(){ |
| 37 | - switch(msg){ | 37 | + return new Promise(function(resolve, reject){ |
| 38 | - case '일본' : | 38 | + switch (msg) { |
| 39 | + case '일본': | ||
| 39 | send = { | 40 | send = { |
| 40 | - 'message' : { | 41 | + 'message': { |
| 41 | - 'text' : '등록된 가수 목록입니다.' | 42 | + 'text': '등록된 가수 목록입니다.' |
| 42 | }, | 43 | }, |
| 43 | - keyboard : { | 44 | + keyboard: { |
| 44 | - 'type' : 'buttons', | 45 | + 'type': 'buttons', |
| 45 | - 'buttons' : ['Reol', '米津玄師', 'yanaginagi', 'ヨルシカ', 'ダズビ', 'Polkadot Stingray', 'Aimyong'] | 46 | + 'buttons': ['Reol', '米津玄師', 'yanaginagi', 'ヨルシカ', 'ダズビ', 'Polkadot Stingray', 'Aimyong'] |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | }; | 49 | }; |
| 49 | break; | 50 | break; |
| 50 | - case '한국' : | 51 | + case '한국': |
| 51 | send = { | 52 | send = { |
| 52 | - 'message' : { | 53 | + 'message': { |
| 53 | - 'text' : '등록된 가수 목록입니다.' | 54 | + 'text': '등록된 가수 목록입니다.' |
| 54 | }, | 55 | }, |
| 55 | - keyboard : { | 56 | + keyboard: { |
| 56 | - 'type' : 'buttons', | 57 | + 'type': 'buttons', |
| 57 | - 'buttons' : ['볼빨간 사춘기', 'MOT', 'Gukkasten', 'ZICO', 'DEAN', 'IU', 'Heize'] | 58 | + 'buttons': ['볼빨간 사춘기', 'MOT', 'Gukkasten', 'ZICO', 'DEAN', 'IU', 'Heize'] |
| 58 | } | 59 | } |
| 59 | }; | 60 | }; |
| 60 | break; | 61 | break; |
| 61 | default: | 62 | default: |
| 62 | - singer.jpSinger(msg).then(function(result){ | 63 | + singer.jpSinger(msg).then(function (result) { |
| 63 | send = result; | 64 | send = result; |
| 64 | }) | 65 | }) |
| 65 | - if(send == '') | 66 | + if (send == '') |
| 66 | send = singer.krSinger(msg); | 67 | send = singer.krSinger(msg); |
| 67 | break; | 68 | break; |
| 68 | } | 69 | } |
| 70 | + if(send){ | ||
| 71 | + resolve(send) | ||
| 69 | } | 72 | } |
| 70 | - delay().then(function(){ | 73 | + reject(new Error("Request is failed")); |
| 71 | - console.log(send); | 74 | + }); |
| 72 | - | 75 | + } |
| 73 | - res.json(send); | 76 | + delay().then(function(result){ |
| 77 | + console.log(result); | ||
| 78 | + res.json(result); | ||
| 74 | }) | 79 | }) |
| 75 | }) | 80 | }) |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment