My fetch response has two parts, an object and an excel file. If I make the server send only the excel file, then response.blob() does the job, but I cant make it work when there's both an object and a file in the response.
but then the excel file turns into a buffer string which gets corrupted when I try to download the file
const json = await response.json()
const formatted_excel_file_or_error = await json.formatted_excel_file_or_error
// turns buffer string into buffer
const buff = await buffer.Buffer.from(formatted_excel_file_or_error,'utf-8')
console.log(buff)
// turns buffer into blob
const blob = await new Blob([new Uint8Array(buff)], {type: 'application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
console.log(blob)
await download(blob, 'test.xlsx', 'application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
My question is, is there a proper way to handle a response that has a file AND object, and if not what am I doing wrong with the conversion from buffer to blob download