Skip to content
Advertisement

Fetch request in React: How do I Map through JSON array of object inside of array of objects?

I managed to fetch API and could output some data in browser, but I couldn’t handle an array of object in JSON. It’s a rest country API, where some countries have more than 1 language. I want to output all languages they speak. Here is the API link. And here is my code

JavaScript

Advertisement

Answer

you should call the languages map inside your country map like:

JavaScript

Also, it is not related with the post, but I’ll suggest you to not use generic names in your .map like item/element/obj

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement