fix: send eMandate encrypted data into form data
This commit is contained in:
@@ -169,7 +169,7 @@ function LoginEmandate() {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
localStorage.setItem("Validate_data", result);
|
localStorage.setItem("Validate_data", result.data);
|
||||||
console.log("Validate Result : ", result);
|
console.log("Validate Result : ", result);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
router.push("/eMandate/otp_page");
|
router.push("/eMandate/otp_page");
|
||||||
|
|||||||
@@ -125,33 +125,80 @@ export default function VerifyOtpPage() {
|
|||||||
|
|
||||||
const success = await verifyOtp(otp, mobile);
|
const success = await verifyOtp(otp, mobile);
|
||||||
|
|
||||||
|
// if (success) {
|
||||||
|
// // 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 formData = new FormData();
|
||||||
|
// const encoded_data = localStorage.getItem("Validate_data");
|
||||||
|
// formData.append("data", encoded_data);
|
||||||
|
|
||||||
|
// const res = await fetch(
|
||||||
|
// "https://apiemandate.kccb.in:9035/EMandate/auth-cbs-resp",
|
||||||
|
// {
|
||||||
|
// method: "POST",
|
||||||
|
// body: formData,
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
if (success) {
|
if (success) {
|
||||||
const encoded_data = localStorage.getItem("Validate_data");
|
try {
|
||||||
const res = await fetch(
|
const encoded_data = localStorage.getItem("Validate_data");
|
||||||
`https://apiemandate.kccb.in:9035/EMandate/auth-cbs-resp?data=${encoded_data}`,
|
if (!encoded_data) {
|
||||||
{
|
console.error("Validate_data not found in localStorage");
|
||||||
method: "POST",
|
return;
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
);
|
const formData = new FormData();
|
||||||
const result = await res.json();
|
formData.append("data", encoded_data);
|
||||||
console.log(result);
|
|
||||||
if (!res.ok) {
|
const res = await fetch(
|
||||||
throw new Error("CBS response API failed");
|
"https://apiemandate.kccb.in:9035/EMandate/auth-cbs-resp",
|
||||||
}
|
{
|
||||||
if (res.ok) {
|
method: "POST",
|
||||||
// navigate only after successful API hit
|
body: formData,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`CBS response API failed: ${res.status}`);
|
||||||
|
}
|
||||||
|
const contentType = res.headers.get("content-type");
|
||||||
|
const result =
|
||||||
|
contentType && contentType.includes("application/json")
|
||||||
|
? await res.json()
|
||||||
|
: await res.text();
|
||||||
|
|
||||||
|
console.log("CBS Response:", result);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
router.push("/eMandate/mandate_page");
|
router.push("/eMandate/mandate_page");
|
||||||
}, 1500);
|
}, 1000);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error("CBS API Error:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setOtp("");
|
setOtp("");
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsVerifying(false);
|
setIsVerifying(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user