Cannot read property 'setState' of undefined (with fetch api) : <p>When I'm trying to set my "users" state's variable, I've got the following message : <br/><em>Cannot read property 'setState' of undefined</em>
<br/> It's on the following code line :<br/><br/>
<code>this.setState({users: data.users});</code></p>

<p>Here is my class </p>

<p>`
import React, { Component } from 'react';</p>

<p>class Users extends Component {</p>

<pre><code>constructor(props) {
    super(props);
    this.state = {
        users: []
    };
}

componentWillMount() {
    this.getUsers();
}

getUsers = () =&gt; {
    let myHeaders = new Headers({
        'Authorization': 'Basic '+btoa('john@doe.com:password'),
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    });

    fetch('https://dev-api/v1/user/', {
        method: 'GET',
        headers: myHeaders
    }).then(function(response) {
        if (!response.ok) {
            throw Error(response.statusText);
        }
        return response;
    }).then(function(response) {
        response.json().then(function(data) {
            this.setState({users: data.users});
        });
    }).catch(function(error) {
        console.log(error);
    });
}

render() {
    return (
        &lt;table className="striped bordered"&gt;
            &lt;thead&gt;
                &lt;tr&gt;
                    &lt;th&gt;email&lt;/th&gt;
                    &lt;th&gt;Firstname&lt;/th&gt;
                    &lt;th&gt;Lastname&lt;/th&gt;
                &lt;/tr&gt;
            &lt;/thead&gt;
            &lt;tbody&gt;
            {this.state &amp;&amp; this.state.users &amp;&amp; this.state.users.map(user =&gt;
                &lt;tr&gt;
                    &lt;td&gt;{user.username}&lt;/td&gt;
                    &lt;td&gt;{user.firstname}&lt;/td&gt;
                    &lt;td&gt;{user.lastname}&lt;/td&gt;
                &lt;/tr&gt;
            )}
            &lt;/tbody&gt;
      &lt;/table&gt;
    );
}
</code></pre>

<p>}</p>

<p>export default Users;`</p>

<p>Thanks a lot !</p>
