0
const countries = require("https://ninjahosting.ninjablade.repl.co/jsHosting/script.js");
let n = 0;
while (n < 198) {
  n++;
  setTimeout(()=>{document.getElementById(elementId).value = countries[(n+1)]; }, delay*n);
}

When I run this code, I get this error

"41:19 Uncaught ReferenceError: require is not defined"

https://jsfiddle.net/6xnqhosk/

That's the fiddle

ponury-kostek
  • 7,824
  • 4
  • 23
  • 31
  • 1
    What JS version are you using? I think you can use ES6 modules to import, export, e.t.c. – Tony M Jan 25 '22 at 17:37
  • your script does not assign your array to any variable. the module.export misses an s (if it was meant to be run in node). Can't you just rename your file as a json and only put your json array in it ? – grodzi Jan 25 '22 at 17:38
  • You can't use `require` in the browser without some build tool. In this case you're better off using a normal `fetch` request. – Phix Jan 25 '22 at 18:00
  • I don't understand what ur saying – Ninjablade Jan 25 '22 at 19:35

0 Answers0