Error on res ['casesbyState'] and can't resolve

72 Views Asked by At

With the following code:

let name = res['casesByState'].map(res => res.name)
     
let casesReported = res['casesByState'].map(res =>res.casesReported)
    
this.chart = new Chart(this.myAreaChart.nativeElement, {
    type: 'line',
    data: {
        labels: name,
        datasets: [
            {
                 data: casesReported,

I get the following type error:

Error: Element implicitly has an 'any' type because expression of type '"casesByState"' can't be used to index type 'Object'. Property 'casesByState' does not exist on type 'Object'.ts(7053)

What is causing this?

0

There are 0 best solutions below