title: React Hooks - Making an Ajax request
body: <p>I have just began playing around with React hooks and am wondering how an AJAX request should look?</p>
  
  <p>I have tried many attempts, but am unable to get it to work, and also don't really know the best way to implement it. Below is my latest attempt:</p>
  
  <pre><code>import React, { useState, useEffect } from 'react';
  
  const App = () =&gt; {
      const URL = 'http://api.com';
      const [data, setData] = useState({});
  
      useEffect(() =&gt; {
          const resp = fetch(URL).then(res =&gt; {
            console.log(res)
          });
      });
  
      return (
          &lt;div&gt;
            // display content here
          &lt;/div&gt;
      )
  }
  </code></pre>