title: set header in react api request in componentDidMount()
body: <p>Hi so the problem i'm struggling with is i have an api with an accesskey and i don't know how to setup the header inside the component with that api access key, i'm using a default fetch random user api in example below but i want to know how and where should i add that header with access key, thanks in advance.</p>
  
  <pre><code>
  
  import React from 'react';
  
  
  export default class FetchRandomUser extends React.Component {
  
  
  
      async componentDidMount() {
          const url = "https://api.randomuser.me/"
          const response = await fetch(url)
          const data = await response.json();
          this.setState({ person: data.results[0], loading: false })
      }
  
      render() {
          return &lt;div&gt;
              {this.state.loading || !this.state.person ? (&lt;div&gt;Loading...&lt;/div&gt;) : (&lt;div&gt;{this.state.person.name.first}&lt;/div&gt;)}
          &lt;/div&gt;
      }
  }
  
  </code></pre>