은승우

Update app.js

Showing 1 changed file with 6 additions and 5 deletions
......@@ -71,7 +71,7 @@ app.post('/webhook', line.middleware(config), (req, res) => {
})
});
// event handler
function handleEvent(event) {
async function handleEvent(event) {
console.log(event.type);
console.log(event.message);
......@@ -81,7 +81,7 @@ function handleEvent(event) {
return Promise.resolve(null);
}
else if (event.type == 'message'&& event.message.type == 'image') {
return new Promise(async(resolve,reject)=>{
return new Promise((resolve,reject)=>{
console.log("!");
var cheerio = require('cheerio');
......@@ -102,7 +102,9 @@ function handleEvent(event) {
},
body: event.message.image
};
await request.post(options, function (error, response, body) {
}).then(
request.post(options, function (error, response, body) {
var data=JSON.stringify(body);
var text='';
console.log(data);
......@@ -137,8 +139,7 @@ function handleEvent(event) {
}
client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
});
});
})
}))
}
else if(event.type == 'message' && event.message.type == 'text')
{
......