Мне нравится отображать возврат моего PHP API в формате PDF

это отображается в моем iframe, когда я передаю большой объект, и это мой исходный код
const displayPDF = async function (attachedFiles) {
const fData = new FormData();
fData.append("attachedFiles", attachedFiles);
const displayPDF = async function (attachedFiles) {
const fData = new FormData();
fData.append("attachedFiles", attachedFiles);
await axios({
method: "POST",
url: `${process.env.NEXT_PUBLIC_API_URL}/getPDF.php`,
data: fData,
responseType: "blob",
config: { headers: { "Content-Type": "multipart/form-data" } },
})
.then((response) => {
// return console.log(response.data);
const url = window.URL.createObjectURL(new Blob([response.data]));
setIframe(url);
})
.catch((error) => {
toast.error(error.response.data);
});
};
useEffect(()=> {
displayPDF();
},[]);
return (
{iframe && (
)}
);
Подробнее здесь: https://stackoverflow.com/questions/783 ... -in-nextjs