title: How to store data from json API response into array in ReactJS?
body: <p>So I have a database set up and I am trying to pull the info from it and store it into a state array so I can use it on the website.</p>
  
  <p>This is an example of what I get when I request form the database, shortened for readability</p>
  
  <pre><code>{
      "count": 10,
      "next": null,
      "previous": null,
      "results": [
          {
              "var1": "Test",
              "var2": "",
              "NeededInfo": "name1",
          },
          {
              "var1": "Test",
              "var2": "",
              "NeededInfo": "name2",
          }
      ]
  }
  </code></pre>
  
  <p>So what I need is to take the NeededInfo of each object and store it into an array so I can use it on render(). This is what I'm trying, but when I do printToConsole() (not shown but just a console.log(this.state)) to see what the state array looks like, the "other" array is undefined</p>
  
  <pre><code>const title_URL = "http://123.456.789/namelist";
  
  class Project extends Component {
    constructor(props) {
      super(props);
  
      this.state = {
        random1: "",
        random2: "",
        other: [],
        items: []
      }
    }
  
    componentDidMount() {
      fetch(title_URL)
        .then(response =&gt; {
          return response.json();
        })
        .then(data =&gt; {
          this.setState({
            other: data.results.NeededInfo
          })
        });
    }
  </code></pre>
  
  <p>I need the "other" array to look like</p>
  
  <pre><code>other: ["name1", "name2"]
  </code></pre>
  
  <p>because in my render() I have to list the names that the site pulls from the database so the user can see the names of the listed items and do some other stuff with it, and then I can save that into the "items" array, in a new order, but that part works with if I have a preset "other" array.</p>