I'm trying to retrieve some data from a json to use later in a chart.
My issue is that using useState, it gets me a never type data, so I can't access fields.
const [myData, setData] = useState([]);
const url = 'url';
axios.get(url)
.then(res => {
setData(res.data);
myData.forEach( e=> {
console.log(e.name);
})
}).catch(function (error) {
// handle error
})
When i print the console.log the name results as an error because Property 'name' does not exist on type 'never'.
How could I fix this?
EDIT: I'm using Typescript