Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Use fetch() to request the HTML file from the server. Call .text() on the Response object you get from the fetch in order to get the HTML contents as a string. You can then insert the string into a...
Answer
#1: Initial revision
Use [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) to request the HTML file from the server. Call [`.text()`](https://developer.mozilla.org/en-US/docs/Web/API/Response/text) on the `Response` object you get from the `fetch` in order to get the HTML contents as a string. You can then insert the string into a DOM node with [`.insertAdjacentHTML()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML) (which is recommended over anything involving `.innerHTML` for performance reasons). `fetch` and `text` return promises, so make sure you have some familiarity with [how those work](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises).