I have a directory on my webserver where I upload timestamp.md files for publishing to my "blog"-div on my site. Using javascript to fetch index of dir via scandir() (PHP) returns:
["2018-12-05T13:28:10.000Z.md","2018-12-05T12:58:19.858Z.md","2018-12-05T12:37:25.012Z.md","2018-12-05T12:28:52.612Z.md","..","."]
I store obve in var "files".
I then do a for-loop with fetch from index.html to get content of all off the timestamp.mds
(I create a emtpy array for storing of md-content)
var mdcontent = new Array()
for(var i=0;i<files.length -2;i++) {
fetch('md/'+files[i])
.then( response => response.text())
.then(result => mdcontent.push(result));
}
console.log(mdcontent) returns what looks like a normal array
consol.log(mdcontent[0]) (or any other element of array) returns undefined.
console.log(mdcontent.lenght) returns 0.
The question is how to access elements of this array?
I cant figure out where I went wrong this time and if someone could help me I would appreciate it!
Thanks in advance