this.setState() is not a function -> when trying to save response on state
<p>I'm trying to save the response of a get request onto a property on state. Here's my code: </p>

<pre><code>import React, { Component } from 'react';
import {render} from 'react-dom';

import './App.css';
import Card from './Card.js';
import SearchBar from "./SearchBar.js"
import star from './images/star.svg';
import wars from './images/wars.svg';
import $ from './../node_modules/jquery';

class App extends Component {

constructor(props){
  super(props);
  this.state = {
    gets: []      //THIS IS WHERE THE RESPONSE ARR SHOULD BE SAVED 
  }
}

////////////////////////////
//     GET REQUEST        //
////////////////////////////

getTheApi(){
$.get('http://localhost:3008/people', function(cool){
    console.log(cool) //&lt;-- the response is correct (array of objs)
    this.setState({gets:cool}).bind(this)   //have tried w/ w/out .bind(this)
  })
}

render() {

console.log(this.state.gets); //shows as undefined

    return (
      &lt;div className='content'&gt;
        &lt;div className='logo'&gt;
          &lt;img src={star} alt="star-logo" /&gt;
          &lt;span className='interview-text'&gt;The Interview&lt;/span&gt;
          &lt;img src={wars} alt="wars-logo" /&gt;
          &lt;span&gt;WHATTTTTT&lt;/span&gt;
        &lt;/div&gt;
        &lt;SearchBar /&gt;
        &lt;Card /&gt;
      &lt;/div&gt;
    );
  }
}

render(&lt;App/&gt;, document.getElementById('app'));
</code></pre>

<p>I've tried multiple ways to get this to work, but no dice. I've tried <code>this.setState({gets:cool})</code> with and without bind. I've console logged the variable <code>cool</code> before <code>this.setState</code> and I am getting the correct array of objects. But when I then try to save my response to state it says </p>

<pre><code>Type Error: this.setState() is not a function.
</code></pre>

<p>I've also tried invoking <code>getTheAPI()</code> inside of render, thinking state wasn't being updated because the function was never being run, but the errors persisted.</p>

<p>I just can't figure out why the response is defined in the function, but not out of the function, and why it's saying <code>this.setState()</code> is not a function.</p>

<p>Help me Obi Wan Kenobi, you're my only hope.</p>