export function downloadFile(url, data = {}, methodType = 'GET') { const form = document.createElement('form'); const formAttrs = [ { name: 'action', value: url, }, { name: 'method', value: methodType }, ]; formAttrs.forEach(attr => { const { name, value } = attr; form.setAttribute(name, value); }); const inputs = []; const allDataKeys = Object.keys(data); allDataKeys.forEach(key => { inputs.push({ name: key, value: data[key] }); }); inputs.push( { name: 'signature-sessionId', value: window.name }, { name: 'language', value: getLocale() } ); inputs.forEach(input => { const inputElem = document.createElement('input'); inputElem.setAttribute('type', 'hidden'); const keys = Object.keys(input); keys.forEach(key => { inputElem.setAttribute(key, input[key]); }); form.appendChild(inputElem); }); document.body.appendChild(form); form.submit(); document.body.removeChild(form); }