Build a Markdown Previewer - FileReader - a little help?

hi All,

I’m busy trying to build my markdown previewer but i’m finding it difficult to read a .txt file from dropbox into a text area. I started with the following code:

var reader = new FileReader();
var file= “https://www.dropbox.com/l/scl/AAChYBKjjs4ecYB73_ajfySqhgH7uOrfIeA”;
var text = reader.readAsText(file);
document.getElementById(‘displayArea’).innerHTML = text;

but i’m getting the following error:
Uncaught TypeError: Failed to execute ‘readAsText’ on ‘FileReader’: parameter 1 is not of type ‘Blob’.

I’ve been reading the documentation but i’m not getting any wiser.
Could someone tell me what i have to do with the url/file to make it a blob type or maybe point me to another source where i can learn more about using the FileReader API.

Thanks alot,
cheers,
Justin

FileReader is for local files only. So you would first need to read the file with fetch API. Also have in mind that you maybe need to use a CORS proxy.

Hopefully this points you into the right direction.

ok. thanks Daniel.
I’ll start reading up on those things now. cheers