I'm trying to fetch pdf file from my backend and display it on the page. I'm using react-pdf library https://www.npmjs.com/package/react-pdf . But I'm getting an error
Invalid parameter in file, need either Uint8Array, string or a parameter object
Could you please help me
import { Document, Page } from 'react-pdf';
<Document file={() => dispatch(downloadAgreement())}>
<Page pageNumber={pageNumber} />
</Document>
export const downloadAgreement = () => (dispatch) => {
return axios(`https://test-zdc/pdf`, {
method: 'GET',
responseType: 'blob'
}).then((res) => {
const file = new Blob([res.data], { type: 'application/pdf' });
const fileURL = URL.createObjectURL(file);
return fileURL;
});
};