How to get source code of a file in JavaScript?

Hello, how do I get the source code of a file in JavaScript? For example, let’s say in my project files there is something named idk test.html. How do I get the code from that?

CRTL + U in the browser let’s you view the source of a page.

No but how do I do that in JavaScript?

Try using Fetch to fetch the file you want.

And how do I use fetch?