전언석

EDIT : when ingredients are more than 2

......@@ -40,9 +40,12 @@ app.post('/hook', function (req, res) {
var index = 0;
var istrue = false;
for (var i = 0; i < results.length; i++) {
if (results[i].ingredients === message.text) {
index = i;
istrue = true;
var ingredients_list = results[i].ingredients.split(", ");
for (var j = 0; j < ingredients_list.length; j++) {
if (ingredients_list[j] === message.text) {
index = i;
istrue = true;
}
}
}
if (istrue) {
......@@ -61,6 +64,10 @@ app.post('/hook', function (req, res) {
},
{
"type": "text",
"text": `필요한 재료는\n${results[index].ingredients} 입니다.`
},
{
"type": "text",
"text": `레시피\n${results[index].recipe}`
}
]
......