은승우

Update app.js

Showing 1 changed file with 3 additions and 5 deletions
...@@ -99,15 +99,13 @@ async function handleEvent(event) { ...@@ -99,15 +99,13 @@ async function handleEvent(event) {
99 }; 99 };
100 100
101 request.post(options, function (error, response, body) { 101 request.post(options, function (error, response, body) {
102 - var data=body; 102 + let jsonResponse = JSON.stringify(JSON.parse(body), null, ' ');
103 - console.log(data);
104 var text=''; 103 var text='';
105 - while(data.indexOf('text\\')!=-1) 104 + while(jsonResponse.indexOf('text\\')!=-1)
106 { 105 {
107 data=data.substring(data.indexOf('text\\')+9); 106 data=data.substring(data.indexOf('text\\')+9);
108 text+=data.substring(0,data.indexOf("\\"))+" "; 107 text+=data.substring(0,data.indexOf("\\"))+" ";
109 } 108 }
110 - text="나의모든날들";
111 var url="https://www.genie.co.kr/search/searchLyrics?query="+ encodeURI(text); 109 var url="https://www.genie.co.kr/search/searchLyrics?query="+ encodeURI(text);
112 request(url, function(error, response, html){ 110 request(url, function(error, response, html){
113 var $ = cheerio.load(html); 111 var $ = cheerio.load(html);
...@@ -132,7 +130,7 @@ async function handleEvent(event) { ...@@ -132,7 +130,7 @@ async function handleEvent(event) {
132 client.replyMessage(event.replyToken,result).then(resolve).catch(reject); 130 client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
133 }); 131 });
134 }); 132 });
135 - 133 +
136 }); 134 });
137 135
138 } 136 }
......