Await still returns a Promise object

Viewed 44

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 })
1 Answers

I just tested it with this code and it worked as expected for me

const verification_check = await client.verify.v2
    .services("VAXXXXXXXXXX")
    .verificationChecks.create({ to: "+49XXXXX", code: "916444" });
console.log(verification_check.status);
// logs "pending" or "approved"

I tested it with the client version ^3.81.0 and ^3.82.1. Are you using an older version?

Related