I have a react web app that is fetching a JSON object from my API on componentDidMount().
I am able to view the data in React dev tools in web browser but i am having trouble mapping the data to HTML. I have done it this way in previous applications but its not working with my current object.
I am sure there is a small problem with the syntax of how I am mapping the array. Thanks for the help.
image of data object from react tools
import React from "react";
import { BrowserRouter as Router, Link, Route } from 'react-router-dom';
class TeamInformation extends React.Component{
state = {teamNames: []}
constructor(props) {
super(props);
this.state = {
selectedTeam: "none"
};
}
componentDidMount(){
fetch('/users/teamNames')
.then(res => res.json())
.then(teamNames => this.setState({teamNames}));
}
render(){
return (
<div>
<h1>Teams</h1>
{this.state.teamNames.map(teamData =>
<div key={teamData.PK_TeamID}>
<p>{teamData.cityName}</p>
</div>
)}
</div>
)}}
export default TeamInformation;