- 여기서 중요한점은 백으로 보낼때 responseType: 'blob'이어야 한다
해당 타입은 params || data에 들어가지 않고 독단적으로 보냄
const downloadCSV = async () => {
const config = {
method: 'post',
responseType: 'blob',
url:'/excel-download'
data: {
...form,
},
}
await AxiosApi(config).then((e) => {
const blob = new Blob([e.data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
})
const link = URL.createObjectURL(blob)
const excelName = document.createElement('a')
excelName.download = `입금완료내역_${today}.xlsx`
excelName.href = link
document.body.appendChild(excelName)
excelName.click()
document.body.removeChild(excelName)
})
}