I have the function below and using the deprecated URL.createObjectURL() method:
const downloadExceptionFile = async () => {
const resp = await getExceptionFile();
const link = document.createElement('a');
link.setAttribute('download', 'excecoes.xlsx');
link.href = URL.createObjectURL(new Blob([resp.data]));
document.body.appendChild(link);
link.click();
link.remove();
};
I`m using react, i try use this.srcObject and this.src as recomended in HTMLMediaElement.srcObject documentation, but, i just got an undefined error in my face.
How can i replace URL.createObjectURL() since this method its deprecated?
CodePudding user response:
Long story short:
You don't need to change that code since URL.createObjectURL() is not deprecated.
The specific use case of creating an object URL to attach to a media element (e.g. <video>) is, and for that you should use .srcObject instead.
