Axios failed to get the binary flow excel returned by the backend

  • the backend uses poi to generate the excel object, and through the stream output, the test code:

ServletOutputStream out = response.getOutputStream ();

        wb.write(out);
        out.flush();
        out.close();
The
  • page sends requests using axios, and according to the blog, responseType: "blob" is also set

Test part of the request:

export function getExcel() {
  return request({
    url: `${BASE_URL}/meta_db/excel`,
    method: "POST",
    responseType: "blob"
  })
}
  • response: obtained from background

clipboard.png

response, response.data

clipboard.png

  • JS response.data, Blob,xls

:


:

clipboard.png

Does anyone know the solution to this problem? Thank you

May.04,2021

is all about buffer what can go wrong. If you can be sure that your excel document generation is OK, then the local system opens excel . To verify it is simple, just compare it with buffer , such as md5 .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3479d-2b694.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3479d-2b694.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?