ERROR getting ::
Uncaught (in promise) TypeError: window.URL.createObjectURL is not a function at eval
unable to download pdf
My code:
axios({
url: url,
method: 'GET',
responseType: 'blob',
headers: {
'Authorization': 'Bearer ' +localStorage.getItem('token'),
}
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf'); //or any other extension
document.body.appendChild(link);
link.click();
});
backend:
public function getPDF(Request $request) {
$pdf = App::make('dompdf.wrapper');
$pdf->loadHTML('<h1><center>Test</center></h1>');
return $pdf->download('invoice.pdf');
}
console.log(window.URL)as the first line in yourthen()callback. What does that show in your console?window.URL.createObjectURL(new Blob());do you get the current URL as a blob?