I have a button on my website that calls a download of an xml, but the following error appears "This XML file does not appear to have any style information associated with it. The document tree is shown below". I believe the browser is trying to open the file, I would like to force the download can someone help me? I'm using Next.js
const url = Services.getXml(id) // o arquivo vem de uma API
fetch(url).then((data) => {
if (data.status == 200) {
const alink = document.createElement('a')
alink.href = url
alink.target = 'blank'
alink.click()
} else {
addToast({ title: 'Erro ao fazer download', type: 'error', duration: 3000 })
}
})
I tried to use Blob but I believe this is not the issue. Or maybe I used it wrong.