I'm attempting to retrieve data from a JSON file in a separate JavaScript file. The goal is to log the title from config.json using main.js.
Exploring the dynamic between JSON and JavaScript in this project has been my current focus. I have experimented with import and export methods, but encountered an "unexpected identifier" error. Extensive research has been done on this topic.
JSON Content:
{
"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);
The desired outcome is for the console to display the title (which is currently set as "pretty cool title"). However, the actual result is an "unexpected identifier" message.