Hello Stack Overflow.
I need help, I am trying to store PDFs offline on a PWA. But first I simply want to retrieve the PDF from the Wordpress REST API and display it in a iframe or even better Pdf.js.
I have successfully managed to GET the a PDF from the API. When testing in postman it displays the PDF that I can scroll through. However, when using the same GET request in a async axios request I get the following.
// Request
async getPDFTest() {
if (typeof indexedDB === 'undefined') {
this.supported = false;
}
await axios.get('https://staging-nasapi.kinsta.cloud/wp-content/uploads/2021/08/Transitions-PG_E.pdf')
.then((response) => {
// handle success
const pdf1 = response;
console.log(pdf1);
})
.catch(() => {
// handle error
console.log('Error getting offline PDF');
});
return new Promise((resolve) => {
resolve();
});
},
};
See console log message below. Image of console log
How can I get this PDF data into an Iframe or Pdf.js?
Thanks