Similar question has definitely been asked before and I tried the solutions provided there, still not able to figure it out.
I am fetching a PDF file stored in Azure blob storage container. Since azure gives me a direct link to access the file, I copied that link and pasted in my browser window and the file gets downloaded.
As per my requirement I need to display that file in browsers new tab, so I tried with following code inside one of the methods:
const config = {
responseType: "blob"
};
try {
const res = await axios.get(apiUrl, config);
const file = new Blob([res.data], { type: "application/pdf" });
const fileURL = URL.createObjectURL(file);
window.open(fileURL, "_blank");
} catch (e) {
console.log(e);
}
by doing this when this method is called, the new tab get opened and closed immediately. How can I keep the new tab opened until user closes it themselves??
