My JSON file is not being properly displayed by my React script. What am I doing wrong? Any help will be appreciated. My App.js file is like:
`
import "./App.css";
import title from "./data/breaking.json";
export default function App() {
const { data } = title
return (
<div className="App">
{data}
</div>
);
}
`
My JSON file is like "./data/breaking.json":
`
{
"pubDate":{
"5":"31-10-2022 06:26:18 UTC",
"1":"31-10-2022 06:26:09 UTC",
"4":"31-10-2022 06:24:07 UTC",
"3":"31-10-2022 06:22:43 UTC",
"8":"31-10-2022 06:21:59 UTC",
"2":"31-10-2022 11:51:04 ",
"7":"31-10-2022 06:20:48 UTC",
"0":"31-10-2022 02:20:33 ",
"9":"31-10-2022 06:20:17 UTC",
"10":"31-10-2022 06:18:00 UTC"
},
"timestamp":{
"5":1667197578.0,
"1":1667197569.0,
"4":1667197447.0,
"3":1667197363.0,
"8":1667197319.0,
"2":1667197264.0,
"7":1667197248.0,
"0":1667197233.0,
"9":1667197217.0,
"10":1667197080.0
}
`
I tried several solutions but none worked. I tried reformatting the JSON file, but that will be costly since the cron is already live. The JSON file gets periodically updated. So I was expecting it to render in real time on the browser.
dataproperty in your JSON.const { data } = titlewill produce - undefined. And nothing will be rendered. If you know this, edit your question - otherwise it's not clear what you are asking.