Load pdf from server and embed in Vue app
First change your expected responseType
to "blob":
return axios.get(`${process.env.VUE_APP_API_INTRANET}/pdf`, { responseType: "blob"})
Also convert the binary response to a Blob
and then generate an object url:
.then(response => { console.log("Success", response); const blob = new Blob([response.data]); const objectUrl = URL.createObjectURL(blob); this.pdfsrc = objectUrl;})
Don't forget to use revokeObjectURL
when finished with it to avoid memory leaks.