title: Calling function from a function in javascript es6
body: <p>I'm using es6 javascript with babel and trying to make an ajax call using xhr using two function but getting an error <code>Uncaught TypeError: this.post is not a function</code></p>
  
  <p>What is the correct syntax to make a call to a function from another function defined in the same class in es6 javascript?</p>
  
  <p>Thanks for your answer this is my code </p>
  
  <pre><code>import alt from '../../alt';
  import cookie from 'react-cookie';
  
  class LoginActions {
    constructor(){
      this.generateActions(
        'updatePassword',
        'updateName',
        'loginSuccess',
        'loginFail',
        'remember'
      );
    }   
      // Generic get request
      post(url, data, callback) {
          var xhr = new XMLHttpRequest();
          xhr.open('POST', url, true);
          xhr.onreadystatechange = function() {
              if (xhr.readyState == 4) {
                  if (xhr.status == 200) {
                      callback(null, xhr.responseText);
                  } else {
                      callback(xhr.statusText);
                  }
              }
          };
          xhr.send(data);
      }
  
      // Get actual content
      login(name, password, remember) {
        var data = "name="+name+"&amp;password="+password+"&amp;remember="+remember;
          this.post('api/login', data, function(err, data) {
              if (!err) {
                this.actions.loginSuccess(data.message);
              } else {
                  this.actions.loginFail(JSON.parse(data.message));
              }
          }).bind(this);
      }
  
  
  
  
  }
  
  export default alt.createActions(LoginActions);
  </code></pre>
  
  <p>Edit1: This is how I call login function / also passed data to xhr request above</p>
  
  <pre><code>handleSubmit(event){
      event.preventDefault();
  
      var name = this.state.name;
      var password = this.state.password;
      var remember = this.state.remember;
  
      LoginActions.login(name, password, remember);
  
    }
  </code></pre>