title: Please fix the continuously array in Postdata react js
body: <pre><code>  const [setdata, fetchdata] = useState([]);
    const [setpostData, Postdata] = useState([]);
  
  
  
    useEffect(() =&gt; {
      getfetchData();
      //this.state.Postdata.length = 0;
      //Postdata([]);
      //getPostData();
    }, [])
  
  useEffect(()=&gt;{
    Object.values(setdata).map((val) =&gt; {
       getPostData(val.Player, val.IP, val.Port, val.ChannelName);
    });
  },[getPostData])          
    function getfetchData() {
      axios.get(&quot;http://localhost:9763/api/getPlayers&quot;,
        {
          headers: {
            &quot;accepts&quot;: &quot;application/json&quot;,
            'Access-Control-Allow-Origin': '*',
          },
          auth: {
            username: 'admin',
            password: 'password'
          },
  
        }).then(response =&gt; {
          //console.log(response.data);
          fetchdata([...Object.values(response.data).flat()]);
  
        }).catch(error =&gt; {
          console.log(error);
        });
    }          
    
        function getPostData(Player,IP,Port,channelName) {
  
      //console.log(&quot;insideFunction Row1&quot;+Player);
      axios({
        method: 'post',
        url: 'http://localhost:9763/api/getPlayerStatus',
        data: {
          PlayerName: Player,
          ChannelName: channelName,
          Port: Port,
          IpAddress: IP
        },
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json',
        },
        auth: {
          username: 'admin',
          password: 'password'
        }
      }).then(response =&gt; {
        //console.log(response.data);
        //Postdata([response.data]);
        Postdata(prevArray =&gt; [...prevArray, response.data])
        //Postdata.push()
      }).catch(error =&gt; {
        console.log(error);
      });
    } 
     
  </code></pre>
  <p>when i reload the page every time i am getting number of post data fetch in my gui
  <a href="https://i.stack.imgur.com/2z8nj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2z8nj.png" alt="enter image description here" /></a>
  i use the object.values in setdata to fetch values
  when i reload the page every time i am getting number of post data fetch in my gui can i use settimeout?</p>
  <p>how can i reinitiate array in post data</p>