Failure in using axios to download pdf (Blank page)

Viewed 1094
 ...
 PdfWriter.getInstance(document, outputStream); // outputstream from java 

I successfully downloaded this pdf file by fetch api and postman, but failed by axios, even though the size was normal.

// I successfully downloaded this pdf file by fetch api and postman, but failed by axios, even though the size was normal(blank content).
axios({
 url: `xxx`,
 method: 'get',
 responseType: 'arraybuffer'
}).then(resp => {
  const url = window.URL.createObjectURL(new Blob([resp.data], {type:"application/pdf"}));
  const link = document.createElement('a');
  link.href = url;
  link.setAttribute('download', 'test.pdf');
  document.body.appendChild(link);
  link.click();
})

Can someone help me?

1 Answers

Remove or uninstall MockJS, and try it again!

Related