Request ID Functions Demo | CHEQ

Request ID Functions Demo

This test dev page is designed to test the CHEQ RTI solution. Once the user has filled out the form, the system will process the information and provide an accurate assessment of the user's IVT (API response). This page serves as an important tool for evaluating and improving the performance of the CHEQ RTI solution, ensuring that it meets the highest standards of reliability.











Submit


Request ID Functions

This function, called “onCheqResponse”, is handling the response received from CHEQ (cheqRequestID). It is using JavaScript and the DOM API to access the top-level window of the current document, and find the element with the id “cheqRequestID” and set its value to the request ID that was passed as an argument to the function. The function uses setTimeout method to wait for 2 seconds before starting the process to wait for the form to load in time. The request ID is associated with the current page and current user session

querySelector

<script>
function onCheqResponse(msg, requestID){
setTimeout(function () {
if(window.top.document.querySelector(‘input[id=”cheqRequestID”]’)) {
window.top.document.querySelector(‘input[id=”cheqRequestID”]’).value = requestID;
}
}, 2000);
}
</script>

 

getElementById

<script>
function onCheqResponse(msg, requestID){
setTimeout(function () {
if(window.top.document.getElementById(“cheqRequestID”)) {
window.top.document.getElementById(“cheqRequestID”).value = requestID;
}
}, 2000);
}
</script>

 

JQUERY

<script>
function onCheqResponse(msg, requestID){
setTimeout(function () {
if($(“#cheqRequestID”).length > 0) {
$(“#cheqRequestID”).val(requestID);
}
}, 2000);
}
</script>

 

Server Side

This function, called “onCheqResponse”, is handling the response received from CHEQ, specifically when the response includes a message and a request ID. It is using JavaScript’s fetch API to make a POST request to the specified url with the requestID as the body of the request. The function uses try and catch statements to handle the error, in case of any error it will log it to the browser’s console using console.error (should be removed on production). Its being used to send the request ID to a server-side script or API endpoint for further processing or storage. It is important to note that the url variable is not defined in the function, and the function will not work as expected until the url is defined and assigned a value.
<script>
function onCheqResponse (msg, requestID) {
try {
var url = “”
fetch(url, { method: ‘POST’, body: requestID }); }
catch (err) {
console.error({ err });
}
}
</script>





Resources

SwaggerHub – Request and Response format and test