function downloadVCard(profile) { fetch("/cms-core/forms/VCard/DownloadVCard/", { method: "POST", body: JSON.stringify(profile), headers: { "Content-Type": "application/json" } }) .then(response => { const filename = response.headers.get('X-Filename'); // Get the filename from the custom header return response.blob().then(blob => [blob, filename]); }) .then(([blob, filename]) => { const url = window.URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = filename; document.body.appendChild(link); link.click(); document.body.removeChild(link); }); }