I’m using Twilio Authy & Verify for mobile number verification. User is sent an authentication code on his phone and I want to verify the code using GET after the user receives and enters it on the page.
The Code is correct and working.
I’m receiving the correct message but I’m having trouble with the IF statement.
//Twilio Response
{
"message":"Verification code is correct.",
"success":true
}
export function button2_click(event) {
const phone = $w("#phone").value;
const code = $w("#code").value;
const verificationCode = $w("#verificationCode").value;
verifyCode(phone, code, verificationCode)
.then( (json) => {
react(json);
});
}
async function react(json) {
$w("#result").text = await json.message; //this is good
if(json.success === 'true') { //here is the trouble
wixLocation.to('/success');
} else {
$w("#error").show();
}
}
As you can see that json.success has to be ‘true’ because my $w(“#result”).text is getting the proper message from the API but still the error keeps showing up instead of the redirect.
I tried converting it to a string like below but its not working
I have been trying to get twilio’s verify API working with the following code, but throws the error :
Can anyone help?=============
===========================Error========================
status:
404
message:
“The requested resource /Services/VA***/Verifications was not found”
code:
20404
moreInfo: “https://www.twilio.com/docs/errors/20404” ====================================
===================== my code=======================
export function authTest(){
var accountSID = ‘AC2***’;
var authToken = ‘fde***’;
var twilio = require (‘twilio’);
var client = new twilio(accountSID, authToken);
Hey Shan/Team, more of a Twilio question I suppose. Where did you find the URLs for Twilio Verify API to be used from Wix’s fetch() calls.
My fetch() calls always return a 404 error.
My URL takes this form :- https://verify.twilio.com/v2/Services --data-urlencode ‘FriendlyName=My First Verify Service’ -u ACxxxxxx:fdxxxxx
The same URL works fine when passed to curl.