Im creating a website using a json file to store the data to be used on one of the pages, but I am struggling to import the data successfully. Im using repl.it to code in.
So far I've tried:
var data = require("data.json")
and got ReferenceError: require is not defined
and
<script src="data.json"></script>
const dta = JSON.parse(data)
and got ReferenceError: data is not defined
And Ive looked at other questions and been really confused by them
Im not sure whether this is related but I also get a syntax error in my json file set out like
data = '[{"foo": "bar"}]'
How can i fix these errors?