I am new to JS and reactJS. I want to get info from API to an array. I made API that show all the info from my database. It looks like this:
const [tempNew, setTempNew] = useState([]);
const getAllWeatherCelsius = () => {
fetch('http://localhost:5000/weather')
.then(response => {
return response.json();
})
.then((jsonData) => {
let tmpArray = [];
for (var i = 0; i < jsonData.length; i++) {
tmpArray.push(jsonData.dayCelsius[i]) <---- here is the error
}
setTempNew(tmpArray);
})
}
I want to collect all values from "dayCelsius" line into array.
What do I need to change in this code?
