Reputation: 3
My browser will display HTML files stored on my computer, and allow them to link to local stylesheets/scripts. It will also display text files. However, it seems like I can't use the Fetch API to access these. Is there any workaround for this?
This is what I have:
fetch('file.md')
.then(response => response.text()
.then(text => {
let target = document.getElementsByClassName('content')[0];
let converter = new showdown.Converter();
converter.setOption('customizedHeaderId', 'true');
converter.setOption('tables', 'true');
let html = converter.makeHtml(text);
target.innerHTML = html;
})
It works fine accessing a normal Internet file.
Upvotes: 0
Views: 56