[BUG]
Environment
Please provide as many details as you can:
We have an issue with Multiple calls in FORM IO, Embedded FORM IO in our website and created a Hidden Field and added JS logic in Custom Default Value to get the Data from End Point, We are able to get data, if we get the Data also it is making calls and unable to edit the Form for other fields and it is stopping us to access the other pages as well.
- Hosting type
- [x] Form.io
- [ ] Local deployment
- Version: ^4.4.0
- Formio.js version:
- Frontend framework: Angular
- Browser: Chrome
- Browser version: 65.*
Steps to Reproduce
- Create a Hidden/Text/Dropdown component
- Add custom logic to validate or get the values for Dropdown Custom Default Value sample code:
Expected behavior
It shouldn't make more than one call
Observed behavior
It is making more than 10 calls for each validation/getting values/
See the below sceenshot, it has more than 10 calls

Example
If possible, please provide a screenshot, live example (via JSFiddle or similar), and/or example code to help demonstrate the issue.
For code or form JSON, please enclose in a code block:
var xhr = new XMLHttpRequest();
xhr.open('POST', 'API Endpoint', false);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if (xhr.status === 200) {
var resp = JSON.parse(xhr.response);
value = [resp];
}
};
//Input Payload
try{
xhr.send(JSON.stringify(
{"actionType":"","payload":{"regionCode":"USSND"}}
));
}
catch(err){}
Will you please provide a running example that includes your custom logic + form json so that we can reproduce the issue?
Please find the attached JSON and let me know if you need anything. FormJson.txt
-- Please refer a demo fiddle showing the Issue :- https://jsfiddle.net/sj8m7ce0/
-- Details :- In the form we have a text field in which we have implemented some validation "onBlur" event. So when we click outside of this textbox it will call a api to validate the input but it making multiple api calls which is the issue ideally it should call api for once but it's making multiple calls.
Attached is the form json and screenshot of multiple API calls(taken from browser dev tools) for reference.
-- Steps to reproduce the Issue :-
- Open the fiddle.
- Open the dev tools(network tab), type something in the text field and focus out from the textbox and see there will be multiple api calls ideally it should be one.
- Repeat step 2 and you will see multiple calls.
@gopikrishna123 After investigating this item, our developer has said that there is not an issue here. After the first validation cycle it considers the component as invalid and that's why it validates it on Change instead of on Blur then (if the component is already invalid, we are triggering validation on each change even if 'Validate On' equals to 'blur') To fix your problem you can just remove 'addEventListener'. Your code should look like:
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://cdn.rawgit.com/mshafrir/2646763/raw/states_titlecase.json', false);
xhr.onload = function() {
console.log(xhr.response);
valid = 'Invalid!';
};
try {
xhr.send();
} catch (err) {}
I hope that this helps.
Thank you.
