0

I get this error: Failed to execute 'blob' on 'Response': body stream already read. when trying to get the blob.

Code reactjs:

export const createCSVPostPrivateAction = async (model, dispatch) => {
 return Post(API_CREATE_CSV_POST_PRIVATE, null, model, null, null)
.then(res => {
  if (res.ok) {
    const file = res.blob();
    saveAs(file, "report.xlsx");

Post function:

  fetch(API, {
  method: 'POST',
  headers: Header('application/json', header),
  body: JSON.stringify(model),
   })
  .then(res => {
    if (convertToJson) {
      if (res.ok) return res.json();
    } else {
      return res;
    }
  })

Code C#:

return File(content, "application/vnd.openxmlformats- 
   officedocument.spreadsheetml.sheet", "baocao.xlsx");

Can someone help me? I am desperate with this !!!!

Chetan
  • 6,380
  • 3
  • 19
  • 32
John
  • 39
  • 1
  • 5
  • Maybe this article will help you:https://stackoverflow.com/questions/56988063/how-to-download-file-using-react-js-and-asp-net-core-v3-0 – Tupac Aug 11 '21 at 07:33

0 Answers0