M
M
maestro072020-03-05 11:31:16
React
maestro07, 2020-03-05 11:31:16

How to open pdf in new tab?

I get inputstream. and show in a new tab. how to check if error without blob? blob cannot take error message

Axios(url, {
  method: 'GET',
  responseType: 'blob'
})
.then((res) => {
  const file = new Blob(
    [res.data],
    {type: 'application/pdf'}
  );
  const fileUrl = URL.createObjectURL(file);
  window.open(fileUrl, "_blank");
})
.catch((e) => {
  this.showNotification("error", "Отсутвствует квартирный лист");
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Cheremkhin, 2020-03-05
@Che603000

There is a similar issue discussed here and possible solutions
https://github.com/axios/axios/issues/1392

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question