Avatar for user116444

user116444

Member since Aug 2020 • Last active Aug 2020
  • 1 conversations
  • 1 comments

Most recent activity

  • in Bangle.js
    Avatar for user116444

    Hi,

    I'm generating several csv files on the bangle.js. Once it's done, I would like to make a convenient tool to download all files at the same time. For that, I'm creating a html tool for the app loader.
    I followed the existing examples and start with:

    <html>
     ...
    var csvData = "";
    
    function getData() {
      fileData = [];
      Util.showModal("Loading...");
      dataElement.innerHTML = "";
      var promise = Promise.resolve();
      Puck.eval('require("Storage").list(/data-............\.csv/)',files=>{
        if (files.length==0) {
          dataElement.innerHTML = "<p>No saved data</p>";
        } else {
          files.forEach(file => {
    

    This works and finds all my files. Then, in the loop, I would like to find a way to download everything at once. A satisfying way would be to concatenate all strings in the variable csvData, and then save it into a unique csv file on my computer. But definitely the best solution would be to save all files individually by pushing one button.
    But I couldn't make it work at all. I'm also very confused about how the code is executed. The code after the loop "forEach" always finish after the code bellow despite not using async.

    Could you give me some direction on how to solve my issue?

    Thanks!

Actions