Hello World...
axios POST 방식으로 파일 다운 받기 본문
location.href 방식으로 다운로드를 받았는데,
axios post 방식으로도 받을 수 있다.
이 때는 response type을 blob 형식으로 받아야 한다.
https://www.npmjs.com/package/js-file-download
모듈을 사용하면 편하다.
https://stackoverflow.com/questions/41938718/how-to-download-files-using-axios
ex)
vue.js
downloadList(payload) {
// location.href = `/admin/getUserListExcel.do?${payload}`;
return $axios.post('/admin/getUserListExcelPost.do', payload, { responseType: 'blob' });
},
import fileDownLoad from 'js-file-download';
const file = await this.downloadList(payload);
fileDownLoad(file.data, 'UserList.xlsx');
'vue.js' 카테고리의 다른 글
vue-echarts 에서 markArea 사용하기 (0) | 2022.12.20 |
---|---|
vite.config.js asset 폴더 이름 변경하기 (0) | 2022.11.15 |
vue3, vue-router4 에서 base path 설정하기 (0) | 2022.10.26 |
nuxt2 base path 설정하기 (0) | 2022.10.25 |
Vue.js3 - fontawesome prefix 에러 나는 경우 (0) | 2022.02.26 |