Instead of receiving actual data in the response, I am getting a set of characters. However, everything works fine when I click on Download file in swagger. Can someone help me diagnose the issue?
function downloadDocFile(data: Blob, ext = 'xlsx', name = 'Export'): void {
const downloadUrl = window.URL.createObjectURL(new Blob([data]))
const link = document.createElement('a')
link.href = downloadUrl
link.setAttribute('download', `${name}-${DateTime.now().toLocaleString()}.${ext}`)
document.body.appendChild(link)
link.click()
link.remove()
}
const loading = useLoading()
function handleExport() {
loading.show()
const url = `/bill-of-material/${bomItems.value[0]?.billOfMaterialId}/available-kits/export-xls`
getApiInstance('kitting')
.post(url, { responseType: 'blob' })
.then((data: any) => {
if (data) {
downloadDocFile(data)
}
loading.hide()
})
}
Please refer to the following screenshots for more information: Response Image Swagger Image
I have attempted to modify the downloadDocFile and handleExport functions, but unfortunately, none of my attempts were successful.