I am trying to import a JSON file into a JavaScript with the following statement
import phone_numbers from "./phoneNumbers.json";
The JavaScript file is loaded as a module into my HTML file like this
<script type="module" src="./scripts/main.js"></script>
When I view The page, I get the following error
TypeError: 'application/json' is not a valid JavaScript MIME type.
I have tried importing it like this
import phone_numbers from "./phoneNumbers.json" assert { type: "json" };
but I get the following error then
SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
How can I import a json file into a JavaScript file correctly
Thanks in advance