diff --git a/src/app/eMandate/otp_page/page.tsx b/src/app/eMandate/otp_page/page.tsx index 5fab32f..d2adf05 100644 --- a/src/app/eMandate/otp_page/page.tsx +++ b/src/app/eMandate/otp_page/page.tsx @@ -126,8 +126,29 @@ export default function VerifyOtpPage() { const success = await verifyOtp(otp, mobile); if (success) { - setTimeout(() => router.push("/eMandate/mandate_page"), 1500); - } else { + const encoded_data = localStorage.getItem("Validate_data"); + const res = await fetch( + `https://apiemandate.kccb.in:9035/Emandate/auth-cbs-resp?data=${encoded_data}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + } + ); + const result = await res.json(); + console.log(result); + if (!res.ok) { + throw new Error("CBS response API failed"); + } + if (res.ok) { + // navigate only after successful API hit + setTimeout(() => { + router.push("/eMandate/mandate_page"); + }, 1500); + } + } + else { setOtp(""); }