How to use the form form to download the file React from the server through Post

the following method came out from Baidu. I tried it and found that it didn"t work

.
// 3.1reactrenderdiv :
<div id="downloadDiv" style={{display:"none"}}></div>  

//3.2 )  :divdiv

downloadDetailData=()=>{  
  
var divElement= document.getElementById("downloadDiv");  
var downloadUrl=`${apiBasePath}/api/xxxxx/downloadDetailData`;  
var params=JSON.stringify({  
     key:"value"  
})  
ReactDOM.render(  
      <form action={downloadUrl} method="post">  
        <input name="params" type="text" value={params}/>   
      </form>,  
      divElement  
  )  
ReactDOM.findDOMNode(divElement).querySelector("form").submit();  
ReactDOM.unmountComponentAtNode(divElement); 
 
} 
Mar.19,2021

let formElement = document.createElement('form');
formElement.style = "display:none;";
formElement.method = 'post';
formElement.action = `${apiBasePath}/api/xxxxx/downloadDetailData`;
formElement.target = 'callBackTarget';
let inputElement = document.createElement('input');
inputElement.type = 'hidden';
inputElement.name = "params" ;
inputElement.value = params;
formElement.appendChild(inputElement);
document.body.appendChild(formElement);
formElement.submit();
document.body.removeChild(formElement);

see what other people have returned to you. If it's blob, then

jsFileDownload (filename, data, mime) {
    let blob = new Blob([data], {type: mime || 'application/octet-stream'})
    if (typeof window.navigator.msSaveBlob !== 'undefined') {
      window.navigator.msSaveBlob(blob, filename)
    } else {
      var blobURL = window.URL.createObjectURL(blob)
      var tempLink = document.createElement('a')
      tempLink.style.display = 'none'
      tempLink.href = blobURL
      tempLink.setAttribute('download', filename)
      if (typeof tempLink.download === 'undefined') {
        tempLink.setAttribute('target', '_blank')
      }
      document.body.appendChild(tempLink)
      tempLink.click()
      document.body.removeChild(tempLink)
      window.URL.revokeObjectURL(blobURL)
    }
  }

if it's url, it's very simple. There's no need for me to write

.
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-1b3b30d-2b5d8.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-1b3b30d-2b5d8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?