title: Fetching data with React useState getting wrong
body: <p>I'm having a problem with this code, can you help me out please?
  I've created an id state to get an id from an API because I need this ID to make another FETCH</p>
  <pre><code>const [id, setId] = useState([])
  
  useEffect(() =&gt; {
      async function fetchData() {
        await fetch('https://cors-anywhere.herokuapp.com/https://dashboard.meraki.com/api/v0/organizations', requestOptions)
          .then(response =&gt; response.json())
          .then(result =&gt;
            setId(...id, result)
          )
          .catch(error =&gt; console.log('error', error))
      }
      fetchData()
    }, [])
  </code></pre>
  <p>So here I have an array of IDs that I will use in the next fetch...</p>
  <pre><code>const [data, setData] = useState([])
  const [isLoading, setIsLoading] = useState(false)
  
  useEffect(() =&gt; {
          setIsLoading(true)
          id.map(companyId =&gt; {
              async function fetchData() {
                  await fetch(`https://cors-anywhere.herokuapp.com/https://dashboard.meraki.com/api/v0/organizations/${companyId.id}/licenses`, requestOptions)
                      .then(response =&gt; response.json())
                      .then(result =&gt;
                          setData([...data, { company: companyId.name, results: result}]))
                      .catch(error =&gt; console.log('error', error))
              }
              setIsLoading(false)
              fetchData()
          })
      }, [id])
  </code></pre>
  <p>The problem here is... I'm getting a NEW &quot;data&quot; for every id, so it's changing every fetch, and I know its because I used [id] at the end of my useState, but I need to get FOR EACH id, a new &quot;data&quot;, how is that possible?</p>
  <p>When I try to render it with an Empty array on the end of useState, it returns me only an empty array, since its just rendering one time. How can I get for each ID that I got in &quot;id&quot; array on the first fetch, a data containing all the results from the second fetch?</p>
  <p>PS: requestOptions are hidden because of the API Key....</p>