1

Hi im trying to download an array as txt file to use later.

The code i Used is the following

Html

  <div class="fixed-div">
    <button onclick="downloadContract()" class="processbutton">Process Smart-Contract</button>
  </div>

Javascript:

function download(filename, text) {
  var element = document.createElement('a');
  element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  element.setAttribute('download', filename);

  element.style.display = 'none';
  document.body.appendChild(element);

  element.click();

  document.body.removeChild(element);
}

function downloadContract(){
  console.log(assetArray)
  download("assets.txt",assetArray);
}

My result is a txt file with the following Result: [object Object],[object Object]

What I'm trying to get is : [id_1,name1],[id_2,name_2]

0 Answers0