Skip to content
Advertisement

how to map an api into a paragraph

Hi I am trying to map an array of an api to display paragraphs for every index within the array. However I keep getting an error :

**> TypeError: undefined is not an object (evaluating

‘post.game_indices.version.name’)**

But when I console log post and use my buttons below it displays what I want and not undefined. So why is it undefined when I want to map the paragraphs?

”’

import React, {useEffect,useState} from ‘react’ import instance from ‘./axios’

const Home = () => {

JavaScript

}

export default Home;

”’

Advertisement

Answer

ok, I recreated your app and found a problem – you should map on array post.game_indices and then display index.version.name

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