title: How to request a file which is last in dir.txt?
body: <p>super newbie here, </p>
  
  <p>I have a dir.txt file in server with a list of .txt files in the folder. I want to load the last file in the list and load it into another function to be put in a div. So far i can load text into div with a direct file name like "content/bugun.txt". But i want this path to be a variable which is set from dir.txt.</p>
  
  <p>I can also console.log the dir.txt but couldn't make the connection. Contents of dir.txt are like this;</p>
  
  <pre><code>20200410.txt
  20200411.txt
  20200412.txt
  20200413.txt
  20200414.txt
  20200415.txt
  20200416.txt
  20200417.txt
  </code></pre>
  
  <p>here is my fetch for dir.txt</p>
  
  <pre><code>&lt;script&gt;
  fetch('content/dir.txt')
    .then(response =&gt; response.text())
    .then((names) =&gt; {
      console.log(names)
    })&lt;/script&gt;
  </code></pre>
  
  <p>and here is my code for pushing txt to div</p>
  
  <pre><code>    &lt;script&gt;
          window.onload = function loadDoc() {
              var xhttp = new XMLHttpRequest();
              xhttp.onreadystatechange = function() {
                  if (this.readyState == 4 &amp;&amp; this.status == 200) {
                      document.getElementById("deneme").innerHTML = this.responseText;
                  }
              };
              xhttp.open("GET", "content/20200417.txt", true);
              xhttp.send();
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>Thank you in advance,</p>