title: How to add a header field with value as api key in react axios request
body: <p>To access my api I need to add a header field: x-api-key to the axios get request with the value as the api key: 12345678.
  How can I do this in react with my current code?</p>
  <pre><code>import &quot;./App.css&quot;;
  import axios from &quot;axios&quot;;
  import { useEffect } from &quot;react&quot;;
  
  function App() {
    useEffect(() =&gt; {
      axios
        .get(&quot;https://challenge.movies.com.au/api/v2/blahblah/movies&quot;)
        .then((res) =&gt; console.log(res.data))
        .catch((err) =&gt; console.log(err));
    }, []);
  
    return &lt;div className=&quot;App&quot;&gt;&lt;/div&gt;;
  }
  
  export default App;
  </code></pre>