You can find my JSON data on this link. What I am having trouble doing is acquiring article data from React.
My code is below. I did not include the JSON get request code in my question as it's not entirely consequential. I used the jQuery $.getJSON method to replace the state of fulldata with the array. So assume that the data is fully there under fulldata.
getInitialState:function(){
return { fulldata: {forthem:[ {articles: [] } ]} }
},
viewer:function(){
return (<ul>
{this.state.fulldata.forthem[0].articles.map(function(makeit, o){
return <li key={o}>{makeit.article}</li>})}
</ul>)
},
What this existing code allows me to do is acquire the first set of articles under emjayweb. However, if I modify the code to this.state.fulldata.forthem[1] I cannot get the second set of articles under cnn. I get a Cannot read property map of undefined error.
debuggerstatement in theviewerfunction right before thereturnemjaywebandcnnall at once or show a set of articles after an event like onClick?cnnbecause changing my[0]to[1]to my map statement does not work.cnnin my JSON file I plan on adding a for loop to my code to show all articles.