title: How can I map through an object in ReactJS?
body: <p>I have a response like this: </p>
  
  <p><a href="https://i.stack.imgur.com/7Whrk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7Whrk.png" alt="enter image description here"></a></p>
  
  <p>I want to display the name of each object inside this HTML:</p>
  
  <pre><code>{subjects.map((item, i) =&gt; (
    &lt;li className="travelcompany-input" key={i}&gt;
      &lt;span className="input-label"&gt;{ item.name }&lt;/span&gt;
    &lt;/li&gt;
  ))}   
  </code></pre>
  
  <p>But it throws an error of <code>subjects.map is not a function</code>.</p>
  
  <p>First, I have to define the keys of the objects where it creates an array of keys, where I want to loop through and show the <code>subject.names</code>.</p>
  
  <p>What I also tried is this: </p>
  
  <pre><code>{Object.keys(subjects).map((item, i) =&gt; (
    &lt;li className="travelcompany-input" key={i}&gt;
      &lt;span className="input-label"&gt;key: {i} Name: {subjects[i]}&lt;/span&gt;
    &lt;/li&gt;
  ))}
  </code></pre>