I\'m getting the following error
Uncaught TypeError: Cannot read property \'appendChild\' of null
myRequest.onreadystatechange @ script.js
Nice answers here. I encountered the same problem, but I tried but I didn't work quite well. I had all the code and links set up fine. The problem is I had put the js file link in the head of the page, so it was loaded before the DOM was loaded. There are 2 solutions to this.
window.onload = () => { //write your code here }
to the bottom of the html file so that it loads last.