Twilio 手机号码验证 - 在 Express 上找不到 VerificationCheck

Twilio mobile number verification - VerificationCheck was not found on Express

未找到请求的资源/Services/serviceSSID/VerificationCheck是控制台中显示的错误 我的密码是

otpLogin:async (req,res)=>{
    console.log(req.body.otp);
    try {
        const isOTP = await client.verify.services(serviceSSID).verificationChecks.create({
            to:`+91${req.body.phone}`,
            code:req.body.otp
        })  
        if(isOTP)console.log(isOTP);
        return res.status(200).json({message:" mobile number verified"})       
    } catch (error) {
        console.log(error.message)
        return res.status(500).json({message:"something went wrong"})
    }
}

此处为 Twilio 开发人员布道师。

来自the documentation

Twilio deletes the verification SID once it’s:

  • expired (10 minutes)
  • approved
  • when the max attempts to check a code have been reached

If any of these occur, verification checks will return a 404 not found error like this:

Unable to create record: The requested resource /Services/VAXXXXXXXXXXXXX/VerificationCheck was not found

If you’d like to double check what happened with a given verification - please use the logs found in the Twilio Console under your Verification Service:

我发现,如果您通过快速单击提交按钮两次来提交表单两次,则验证已成功检查,然后因为成功删除,第二次检查失败并返回 404,并且那就是您看到的错误结果。为避免这种情况,您应该通过在第一次尝试后禁用提交按钮来阻止用户提交两次表单。