title: Why can't my JavaScript Class's method call a neighbouring method?
body: <p>It seems the <code>buildGeoLocation()</code> method cannot run <code>this.requestHandler()</code> but I can't seem to work out why.<br />
  The console shows <code>Uncaught TypeError: this.requestHandler is not a function</code>.</p>
  <p>Below is my code:</p>
  <pre><code>class Geolocation {
      constructor() {
          this.elements = {
              section: document.querySelector('.james-section'),
              button: document.querySelector('.james-button'),
          }
  
          this.elements.button.addEventListener('click', this.buildGeoLocation)
      }
  
      buildGeoLocation() {
          Promise.all([
              this.requestHandler(&quot;https://freegeoip.app/json/&quot;),
              this.requestHandler(&quot;geolocation-template.html&quot;)
          ]).then(function(values) {
              const data = JSON.parse(values[0]);
              const markup = values[1]
                  .replace('[ip]', data.ip)
                  .replace('[city]', data.city)
                  .replace('[country]', data.country_name)
                  .replace('[lat]', data.latitude)
                  .replace('[lng]', data.longitude);
  
              elements.section.innerHTML = markup;
          }).catch(function(reason) {
              console.log(reason);
          });
      }
  
      requestHandler(url) {
          return new Promise(function(resolve, reject) {
              const xhttp = new XMLHttpRequest();
              xhttp.onreadystatechange = function() {
                  if(this.readyState == 4) {
                      if(this.status == 200) {
                          resolve(this.responseText);
                      } else {
                          reject('Call Failed');
                      }   
                  }
              };
              xhttp.open(&quot;GET&quot;, url);
              xhttp.send();
          });
      }
  }
  
  new Geolocation;
  </code></pre>
  <p>I'm quite new to using Classes so any pointers would be much appreciated </p>