We are trying to use Twilio's verification service, but when we try to return the status from the verification service response, we keep getting undefined. We console.log the response and it's returning [object Promise] even though we are awaiting the function. Below is our code:
exports = async function ({phone, code}) {
const accountSid = context.values.get("twilio-account-sid-value")
const authToken = context.values.get("twilio-auth-token-value")
const smsSid = context.values.get("twilio-sms-verify-sid")
const twilio = require("twilio")(accountSid, authToken)
const verificationResponse = await twilio.verify.v2
.services('VAaa702c9268b7b2c7801b6e4bbd43b3ab')
.verificationChecks.create({ to: phone, code: code })
console.log(verificationResponse)
...
verificationResponse is logging as [object Promise]. How is await still returning a promise? We are also using await when invoking this whole function as below
const response = await realm.currentUser.callFunction("twilio/smsCheckVerify", { phone:phone, code:code })