Showing
1 changed file
with
7 additions
and
6 deletions
... | @@ -71,7 +71,7 @@ app.post('/webhook', line.middleware(config), (req, res) => { | ... | @@ -71,7 +71,7 @@ app.post('/webhook', line.middleware(config), (req, res) => { |
71 | }) | 71 | }) |
72 | }); | 72 | }); |
73 | // event handler | 73 | // event handler |
74 | -function handleEvent(event) { | 74 | +async function handleEvent(event) { |
75 | console.log(event.type); | 75 | console.log(event.type); |
76 | console.log(event.message); | 76 | console.log(event.message); |
77 | 77 | ||
... | @@ -81,7 +81,7 @@ function handleEvent(event) { | ... | @@ -81,7 +81,7 @@ function handleEvent(event) { |
81 | return Promise.resolve(null); | 81 | return Promise.resolve(null); |
82 | } | 82 | } |
83 | else if (event.type == 'message'&& event.message.type == 'image') { | 83 | else if (event.type == 'message'&& event.message.type == 'image') { |
84 | - return new Promise(async(resolve,reject)=>{ | 84 | + return new Promise((resolve,reject)=>{ |
85 | console.log("!"); | 85 | console.log("!"); |
86 | var cheerio = require('cheerio'); | 86 | var cheerio = require('cheerio'); |
87 | 87 | ||
... | @@ -89,7 +89,7 @@ function handleEvent(event) { | ... | @@ -89,7 +89,7 @@ function handleEvent(event) { |
89 | let endpoint = process.env['COMPUTER_VISION_ENDPOINT']; | 89 | let endpoint = process.env['COMPUTER_VISION_ENDPOINT']; |
90 | console.log("?"); | 90 | console.log("?"); |
91 | var uriBase = endpoint + 'vision/v2.1/ocr'; | 91 | var uriBase = endpoint + 'vision/v2.1/ocr'; |
92 | - var options = { | 92 | + var options = { |
93 | uri: uriBase, | 93 | uri: uriBase, |
94 | qs: { | 94 | qs: { |
95 | visualFeatures: 'Categories', | 95 | visualFeatures: 'Categories', |
... | @@ -102,7 +102,9 @@ function handleEvent(event) { | ... | @@ -102,7 +102,9 @@ function handleEvent(event) { |
102 | }, | 102 | }, |
103 | body: event.message.image | 103 | body: event.message.image |
104 | }; | 104 | }; |
105 | - await request.post(options, function (error, response, body) { | 105 | + |
106 | + }).then( | ||
107 | + request.post(options, function (error, response, body) { | ||
106 | var data=JSON.stringify(body); | 108 | var data=JSON.stringify(body); |
107 | var text=''; | 109 | var text=''; |
108 | console.log(data); | 110 | console.log(data); |
... | @@ -137,8 +139,7 @@ function handleEvent(event) { | ... | @@ -137,8 +139,7 @@ function handleEvent(event) { |
137 | } | 139 | } |
138 | client.replyMessage(event.replyToken,result).then(resolve).catch(reject); | 140 | client.replyMessage(event.replyToken,result).then(resolve).catch(reject); |
139 | }); | 141 | }); |
140 | - }); | 142 | + })) |
141 | - }) | ||
142 | } | 143 | } |
143 | else if(event.type == 'message' && event.message.type == 'text') | 144 | else if(event.type == 'message' && event.message.type == 'text') |
144 | { | 145 | { | ... | ... |
-
Please register or login to post a comment