I'm trying to get data from a JSON file from a different javascript file. I want to console log the title from config.json via main.js.
I am trying to learn about JSON and javascript and how they interact with this project. I have already tried using import and export, it tells me that is an unexpected identifier. I have tried researching it lots.
JSON Code:
{
"Info": {
"title": "Pretty Cool Title",
"bio": "Pretty cool bio too in my opinion."
}
}
Javascript Code:
import Info from "config.json";
var info = Info
var title = info.title
console.log(title);
My expected outcome is that the title (which I set to "pretty cool title") will be logged in the console. My actual result however is "unexpected identifier"