node-authy
node-authy copied to clipboard
cannot run authy in twilio function?
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);
};