I have been trying to fix this Cross-site Scripting XSS vunlerability reported during snyk scanning.
const form = document.createElement('form');
form.method = 'POST';
form.action = data.action;
const element = document.createElement('input');
element.setAttribute('value', 'value_1');
element.setAttribute('name', 'name_1');
element.setAttribute('id', 'id_1');
form.appendChild(element);
document.body.appendChild(form);
//At this .appendChild Synk scan is detecting a XSS vulnerability
form.submit();
It is being reported at line, at appendChild method: –
document.body.appendChild(form);
Please, help me fix this vulnerability.