How do I list a GraphApi response with React?

1

I've been trying to create a simple list of the names of the events that I get from a request for GraphApi from Facebook. The object I get is the following:

How do I list only event names? for example:

John Mayer ....
Popload ....
Torments ...
...

    
asked by anonymous 19.06.2017 / 07:30

1 answer

1

Within this events you have an array of objects, so in your render you can have something like this:

(Assuming that events is in state as this.state.events )

render() {
  const events = this.state.events;
  const eventsItems = events ? events.data.map(
    event => (<p key={event.id}>{event.description}</p>)
  ) : [];
  return (
     <div>
        {events}
     </div>
  );
}
    
19.06.2017 / 07:35