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 .

Menu