For webdev context I want my index.js to import index.json.
When I make use of require() I receive the JSON on my VSCode debug console, but on my browser I get the error ReferenceError: require is not defined
try {
const dataJson = require('./index.json');
console.log(dataJson[0]);
} catch(e) {
console.log(e);
}
But when I use import, I receive the JSON on my browser, but my VSCode console returns an exception Uncaught SyntaxError: Cannot use import statement outside a module
import jsonImport from './index.json' assert {type: 'json'};
console.log(jsonImport[0]);
Can I get some leads on how to properly import JSON to my .js files?