title: multiple fetch in useEffect - fetch data depend on another fetch data
body: <p>I am struggle to make a multiple times fetch in useEffect.
  for understand I got to 2 Collection in my mongoDB.</p>
  <p>the backend works, I test the request and I do go the data, so my problem is in the frontend.</p>
  <p>because I am using async function the first function doesn't finish to get the data that is necessary to the second fetch data, that issue give me an error that the value is undefined (if I type the static id and not the loadedState everything work)</p>
  <p>the code:</p>
  <pre><code>  const [loadedContent, setLoadedContent] = useState();
    const [loadedSectors, setLoadedSectors] = useState();
  
    useEffect(() =&gt; {
      const fetchContent = async () =&gt; {
        try {
          //get the first document (we need the web id)
          const responseData = await sendRequest(
            process.env.REACT_APP_BACKEND_URL + &quot;/maincontent/&quot;
          );
          responseData.content.forEach((content, index) =&gt; {
            content.serial = index + 1; //add serial number (1,2,3...)
          });
          setLoadedContent(responseData.content);
        } catch (err) {}
      };
  
      const fetchSectors = async () =&gt; {
      //get the second document that depend on the web id = loadedContent[0].id
        try {
          const responseData = await sendRequest(
            process.env.REACT_APP_BACKEND_URL +
              &quot;/sector/&quot; +
              loadedContent[0].id +
              &quot;/AllSectors&quot;
          );
          responseData.sectors.forEach((sector, index) =&gt; {
            sector.serial = index + 1; //add serial number (1,2,3...)
          });
          setLoadedSectors(responseData.sectors);
        } catch (err) {}
      };
      fetchContent();
      fetchSectors();
       }, [sendRequest]);
  </code></pre>
  <p>the error:
  the data that you see I got is the fetchContent, the data I don't get is the fetchSectors<br />
  <a href="https://i.stack.imgur.com/u2GBC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u2GBC.png" alt="enter image description here" /></a></p>