I'm trying to create Rick&Morty page like the original Rick&Morty-api
But I have problems with the First seen in: line , where you can see on which episode the character appeared for the first time.
I've used useEffect to get all characters and rendered them. It was the easest part, but I don't understand how to get name of episodes , where character appears for the 1st time. And It should work on each page, when I change my page by my pagination. Maybe I should match episodes id with characters id. I really want to work out this problem. So please direct me somehow:)
You already have a list of episodes which should contain the episode id and name. You already get the episode id from character.match, so you should be able to do something like:
let episodeName = episodes.find(e => e.id == character.episode[0].match(/\d+/)[0]).name;
For the particular context of your output jsx, I think this will work:
<h3 className="character_location">
{episodes.length > 0 && episodes.find(e => e.id == character.episode[0].match(/\d+/)[0]).name}
</h3>