I can't seem to read local files using the fetch api, here's my code:
fetch('sometext.txt')
.then(res => {
return res.text()
}).then(text => {
console.log(text)
});
It gave me a "CORS request not http". So I looked up for solutions and changed the mode to "no-cors". But I can't access the text because of the mode "no-cors".
fetch('sometext.txt', { mode: 'no-cors' })
.then(res => {
return res.text()
}).then(text => {
console.log(text)
});
The console.log(text) merely prints out an empty string.
Are there ways to fix it?