I’m new to Typescript and I have to get a list of books from an API. My profesor gave me the code in javascript to do this, but I have to do this in typescript.
Example in Javascript
return (
<div className="List">
{apiData?.map(item => (
<div className="Livro">
<h3> {item.name}</h3>
<p> {item.authors.join(',')}</p>
<p><a href={item.url} target='_blank' rel="noreferrer"> {item.url}</a></p>
</div>
))}
</div>
);
I tried to do this the same way in typescript, but it return this error:
Type error: Property ‘map’ does not exist on type ‘Readonly<{}> & Readonly<{ children?: ReactNode; }>’.
Is there any way to resolve this error or another way to map an API without using map()?