During a .map from an array of data, I have another array of data, which I need to do a .map inside it too. It's looking a bit like this
First Data load
async function handleSubmit(event: FormEvent){
event.preventDefault();
await api.get(`people/?search=${input}`).then(response =>{
setCharacters(response.data.results)
})
}
Second Data Load
async function getFilmName(film: string) {
const movie = film.split("/");
await api.get(`films/${movie[5]}`).then(response =>{
return(response.data.title)
})
}
and then, the .map's
{characters.map(characters =>{
return (
<div>
<Link to={`character/${characters.url.split("/")[5]}`}>{characters.name}</Link>
{characters.films.map((films) =>{
return(
<h5>{getFilmName(films)}</h5>
)
})}
</div>
)
})}
and, in the end I receive a
Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.