I wrote a function that fetches arraybuffer data from my API, generates a temporary anchor element on the webpage, and then triggers a click event to download the file.
Interestingly, this function performs as expected in Chrome.
@action
async loadVoucher(id, fiscalId) {
const pdf = await this.httpClient.get(...);
console.log("load Voucher: ", pdf);
const blob = new Blob([pdf.data], { type: "application/pdf" });
var link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = "Dossier_" + new Date() + ".pdf";
console.log("before link click");
link.click();
link.remove();
}
The usage of @action
is derived from mobx. However, when testing this functionality in Firefox, the second console log (before click link) appears in the browser console (first log displays the data correctly), but the download process fails to initiate.
Iām puzzled by this issue ā any insights on what might be going wrong?