Force download GET request using axios Force download GET request using axios vue.js vue.js

Force download GET request using axios


You're getting empty PDF 'cause no data is passed to the server. You can try passing data using data object like this

  axios    .post(`order-results/${id}/export-pdf`, {      data: {        firstName: 'Fred'      },      responseType: 'arraybuffer'    })    .then(response => {      console.log(response)      let blob = new Blob([response.data], { type: 'application/pdf' }),        url = window.URL.createObjectURL(blob)      window.open(url) // Mostly the same, I was just experimenting with different approaches, tried link.click, iframe and other solutions    })