은승우

Update app.js

Showing 1 changed file with 7 additions and 6 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');
......@@ -89,7 +89,7 @@ function handleEvent(event) {
let endpoint = process.env['COMPUTER_VISION_ENDPOINT'];
console.log("?");
var uriBase = endpoint + 'vision/v2.1/ocr';
var options = {
var options = {
uri: uriBase,
qs: {
visualFeatures: 'Categories',
......@@ -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')
{
......