Estoy tratando de abrir un archivo PDF en una nueva pestaña y quiero leer el archivo sin descargarlo en la máquina local.
Intenté esta función, pero no está cargando mi pdf y da error no se puede cargar el pdf
function readFileInNewTab (fileId) { let url = BASE_URL + "api/CMS/Documents/Download/" + fileId; const requestOptions = { method: 'GET', headers: { 'Content-Type': 'application/pdf', ...authHeader(url) }, credentials: 'include', responseType: "blob", // important }; inProgress = true; return fetch (url, requestOptions).then(handleResponse) .then((response)=> { const file = new Blob([response], { type: "application/pdf" }); //Build a URL from the file const fileURL = URL.createObjectURL(file); //Open the URL on new Window debugger const pdfWindow = window.open(); pdfWindow.location.href = fileURL; }) .catch((error) => { console.log(error); }); } ```