How can get an HTML, CSS, JS replit to serve a txt file

I would like my JS code to fetch a .txt file form the server. That doesn’t seem possible. Neither is adding an href with a reference to a txt file working. However, if change the file extension to .js or .html extension, both work.

what are you using for the back-end? could you send a link to your Repl?

it is just a plain vanilla HTML, CSS, JS default replit

oh, you said “server” so I got confused.

Can you send the link to your repl? We need to see what are you doing with your code.

Unfortunatly, i can’t share this code. It is strange the exact same JS function and same HTML Aref in a new HTML/JS/CSS replit work. I wonder what prevents my original code from loading a .txt file but not to load a .js file. I`ll keep trying to figure out.

You can use a fetch request to do this:

	.then((res) => res.text())
	.then((txt) => console.log(txt));