최지민

search_option7

Showing 1 changed file with 13 additions and 7 deletions
......@@ -79,13 +79,19 @@ function handleEvent(event) {
};
request.get(search_options, function(error, response, body){
if (!error && response.statusCode == 200){
var link = JSON.parse(body).items[0].link;
var description = JSON.parse(body).items[0].description;
var result = { type: 'text', text:
title + " : " + description +
"\n\nlink : " + link
};
// 검색 결과가 없을 경우
if(JSON.parse(body).items == []){
var result = { type : 'text', text : "검색 결과가 없습니다."};
}
else{
var link = JSON.parse(body).items[0].link;
var description = JSON.parse(body).items[0].description;
var result = { type: 'text', text:
title + " : \n" + description +
"\n\nLink : \n" + link
};
}
client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
}
......