I have backend link which I click (or pass it to tag) it starts downloading. How can I display i? I dont want users to be able to download it, just want to display it in my react component.
I already tried something like this:
async function createFile(url) {
let response = await fetch(url);
let data = await response.blob();
let metadata = {
type: "application/pdf",
};
let file = new File([data], "12121.pdf", metadata);
return file;
}
const [file, setFile] = useState();
useEffect(() => {
if (pdf) {
setFile(createFile(pdf));
}
}, [pdf])
and then i tried to display it by
<embed src={file} width="800px" height="2100px" />
but it doesnt seems to work..