title: Unable to get data using Fetch API in React
body: <p>I've the following function that makes and api call and gets data.</p>
  
  <pre><code>export function getUserData(url){
  
    return fetch(url, { credentials : 'include'})
                .then((response) =&gt; { return response.json()})
                .then((data) =&gt;{ return new User(data.uid, data.givenName, data.familyName)})
  }
  </code></pre>
  
  <p>This is my User object.</p>
  
  <pre><code>class User{
    constructor(uid, givenName, familyName){
  
      this.uid = yguid;
      this.givenName = givenName;
      this.familyName = familyName;
    }
  }
  export default User;
  </code></pre>
  
  <p>Now in my react component I'm trying to instantiate the User object.</p>
  
  <pre><code>class Header extends React.Component {
  
      constructor(props) {
        super(props);
        this.state = { fullName: null, yguid: null };
  
      }
      componentWillMount(){
         user = getUserData(url);
         console.log(user);
         //set state with User data
      }
  </code></pre>
  
  <p>I've the following import statements in my React component.</p>
  
  <pre><code>import User from '../models/user';
  import '../api/util';
  </code></pre>
  
  <p>Both my user and function getUserData are undefined. What am I doing wrong and how do I fix it. Thanks in advance.</p>