node-authy icon indicating copy to clipboard operation
node-authy copied to clipboard

cannot run authy in twilio function?

Open dnwk opened this issue 2 years ago • 0 comments

When I try below code in Twilio Functions, I got uuid is not defined error. So authy.send_approval_request was never run? There is no other error messages.

exports.handler = function(context, event, callback) {
var callbacktext = 'Unknown';

var authy = require('authy')('{My APIKEY}')
var payload = {
  "message": "Doorman Request"
}
var authy_id = '{my device id}'

authy.send_approval_request(authy_id, payload, logos=null, function (err, res) {
  console.log(res.approval_request.uuid)
  uuid = res.approval_request.uuid
  console.log(uuid)
});
setTimeout(() => {  
     console.log('timeout')
}, 5000);
authy.check_approval_status(uuid, function (err, res) {
  callbacktext = res.approval_request.status
});
  return callback(null,callbacktext);
};

dnwk avatar Nov 22 '22 17:11 dnwk