title: Why do I get a TypeError: this.getToken is not a function - React JS
body: <p>I've created a login page that consumes a json API. The login page generates a token upon successful authentication and directs the user to a page that will consist of three dropdown boxes. In focusing on just one of the dropdown boxes, I'm attempting to have the dropdown box to display the client's user name according to their token.</p>
  
  <p>The login page calls a function from another react JS page that authenticates the user. </p>
  
  <p>The function:</p>
  
  <pre><code>getToken() {
          // Retrieves the user token from localStorage
          return localStorage.getItem('id_token')
      }
  </code></pre>
  
  <p>In my landing page, which contain the dropdown box, I have the following code:</p>
  
  <pre><code>   componentDidMount() {
          fetch('http://theClientAPI:1111/api/clients', {
              method: 'GET',
              headers: {
                  'Content-type': 'application/json',
                  'Authorization': `Bearer ${this.getToken()}`
              },
          })
          .then(results =&gt; results.json())
          .then(data =&gt; this.setState({ data: data }))
      }
  </code></pre>
  
  <p>In the render() section, I have the following:</p>
  
  <pre><code> &lt;div&gt;
          &lt;select className="custom-select" id="clientName"&gt;
                  { this.state.data.map(item =&gt;(
                  &lt;option key={item.clientName}&gt;{item.clientName}&lt;/option&gt;
                  ))
                  }
              &lt;/select&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>The error appears on this line of my Fetch:  </p>
  
  <pre><code>'Authorization': `Bearer ${this.getToken()}`
  </code></pre>
  
  <p>Could I get some assistance as to what I'm doing wrong? Please let me know if you require more information. I posted the code behind my login and the authentication page below:</p>
  
  <p>Login Page: <a href="https://codepen.io/lkennedy009/pen/GdYOYe?editors=0010#0" rel="nofollow noreferrer">https://codepen.io/lkennedy009/pen/GdYOYe?editors=0010#0</a>
  AuthService Page: <a href="https://codepen.io/lkennedy009/pen/xjyPMY" rel="nofollow noreferrer">https://codepen.io/lkennedy009/pen/xjyPMY</a></p>