I have a directory of text files called ./text-files. I can read files using the fetch API like this:
fetch('./text-files/foo.txt')
then(res => {
return res.text()
})
.then(text => {
console.log(text)
})
Does the fetch API support some way to read a directory of files without knowing the specific name of the files only the file extension?
Ideally, I'd like some way to get a list of all files in the directory ./text-files and then read each one serially using fetch. Is this possible? If it's possible to read one file off disk in Javascript, I would think there'd be some way to get a list of file and read each of them?
I was trying to do something like this, which didn't work:
fetch('./text-files/*.txt')
then(res => {
return res.text()
})
.then(text => {
console.log(text)
})