score:0

Accepted answer

i only need to say to typescript that the object can access a [key: string]: value: any on the iresponse interface!

like:

interface iresponse {
  [key: string]: your-value-type
  [...]
}

score:2

i see 2 different issues here. first you have to call print values return <ul>{printvalues()}</ul>. second you are not handling when person.data is empty on the first render before the data is fetched.

update after comment: alright since you have these the actual way to fix the type error is like this

    let key: keyof iresponse['data'];
    for (key in person.data) {

the issue is you do not have any string type keys. so you need to say you are using the keys of that object

if you dont like that syntax you can always use the following instead

for (let [key, value] in object.entries(person.data))

Related Query

More Query from same tag