I just started to teach myself some React. In my first project I'm trying to create some basic charts with data from an Corona Dataset. The dataset gets created by my own restapi and looks like this:
[{
"Bundesland": "Bayern",
"Landkreis": "LK Erlangen-Hu00f6chstadt",
"Altersgruppe": "A80+",
"Geschlecht": "W",
"AnzahlFall": 1,
"AnzahlTodesfall": 0,
"Meldedatum": 1577836800000,
"IdLandkreis": "09572",
"Datenstand": "05.01.2021, 00:00 Uhr",
"NeuerFall": 0,
"NeuerTodesfall": -9,
"NeuGenesen": 0,
"AnzahlGenesen": 1
},
{
"Bundesland": "Nordrhein-Westfalen",
"Landkreis": "SK Ku00f6ln",
"Altersgruppe": "A35-A59",
"Geschlecht": "W",
"AnzahlFall": 1,
"AnzahlTodesfall": 0,
"Meldedatum": 1577923200000,
"IdLandkreis": "05315",
"Datenstand": "05.01.2021, 00:00 Uhr",
"NeuerFall": 0,
"NeuerTodesfall": -9,
"NeuGenesen": 0,
"AnzahlGenesen": 1
}]
After I fetched the data by using the useEffect-Hook, I'm trying to use the useState-Hook to declare a new data variable that I can pass different react components
My current code method looks like this:
const [corona, setCorona] = useState([])
useEffect(() => {
d3.json(path).then(res => {
let data = res
setCorona(data)
}).catch(err =>{console.log(err)})
},[])
I assume that the api call is working, since i can log the result. However, I am not able to declare corona by using my current setCorona method
Edit: This is the response from the api call
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…