은승우

Update app.js

Showing 1 changed file with 4 additions and 6 deletions
...@@ -81,7 +81,7 @@ async function handleEvent(event) { ...@@ -81,7 +81,7 @@ async function handleEvent(event) {
81 return Promise.resolve(null); 81 return Promise.resolve(null);
82 } 82 }
83 else if (event.type == 'message'&& event.message.type == 'image') { 83 else if (event.type == 'message'&& event.message.type == 'image') {
84 - return new Promise((resolve,reject)=>{ 84 + return new Promise(async(resolve,reject)=>{
85 console.log("!"); 85 console.log("!");
86 var cheerio = require('cheerio'); 86 var cheerio = require('cheerio');
87 87
...@@ -102,9 +102,7 @@ async function handleEvent(event) { ...@@ -102,9 +102,7 @@ async function handleEvent(event) {
102 }, 102 },
103 body: event.message.image 103 body: event.message.image
104 }; 104 };
105 - 105 + await request.post(options, function (error, response, body) {
106 - }).resolve((options)=>{
107 - request.post(options, function (error, response, body) {
108 var data=JSON.stringify(body); 106 var data=JSON.stringify(body);
109 var text=''; 107 var text='';
110 console.log(data); 108 console.log(data);
...@@ -117,7 +115,7 @@ async function handleEvent(event) { ...@@ -117,7 +115,7 @@ async function handleEvent(event) {
117 text="나의모든날들"; 115 text="나의모든날들";
118 console.log(text); 116 console.log(text);
119 var url="https://www.genie.co.kr/search/searchLyrics?query="+ encodeURI(text); 117 var url="https://www.genie.co.kr/search/searchLyrics?query="+ encodeURI(text);
120 - request(url, function(error, response, html){ 118 + request(url, function(error, response, html){
121 var $ = cheerio.load(html); 119 var $ = cheerio.load(html);
122 const $bodyList= $('#body-content > div.search_lyrics > div.music-list-wrap.type-lyrics > table > tbody > tr'); 120 const $bodyList= $('#body-content > div.search_lyrics > div.music-list-wrap.type-lyrics > table > tbody > tr');
123 121
...@@ -139,7 +137,7 @@ async function handleEvent(event) { ...@@ -139,7 +137,7 @@ async function handleEvent(event) {
139 } 137 }
140 client.replyMessage(event.replyToken,result).then(resolve).catch(reject); 138 client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
141 }); 139 });
142 - }) 140 + });
143 }) 141 })
144 } 142 }
145 else if(event.type == 'message' && event.message.type == 'text') 143 else if(event.type == 'message' && event.message.type == 'text')
......