title: How can i pass html input data to a javascript class
body: <p>I am trying to pass data from html input to a vanilla JS class constructor.
  this is what I have tried.</p>
  
  <pre><code>class Users {
    constructor(email,password) {
      this.email = email;
      this.password = password;
  
    }
  
  
    login(){
        // url for endpoint
  let url = "http://127.0.0.1:5000/api/v2/users/login"
  
  alert(this.password)
  
  // get login data from ui
  let data = {
    email : this.email,
    password : this.password
  };
  
  }
  let email = document.getElementById('email').value,
  let password = document.getElementById('password').value
  const user = new Users(email,password)
  document.getElementById('login').addEventListener('submit', user.login())
  </code></pre>
  
  <p>It seems no data is passed to the email and password variables.</p>
  
  <p>I have also tried to do this but the object is not called</p>
  
  <pre><code>class Users {
    constructor(email,password) {
      this.email = email;
      this.password = password;
  
    }
  
          login(){
      // user the data here
  
  }
  function load(event){
     let email = document.getElementById('email').value,
     let password = document.getElementById('password').value
     const user = new Users(email,password)
     user.login()
  }
  
  document.getElementById('login').addEventListener('submit', load)
  </code></pre>
  
  <p>Someone help me on how to work on this.</p>