Can you explain this react function?

This is the function that fetches the products from the database for the products page of a eCommerce website.

I am trying to write a similar function for sign-in.

Can you help me with that I am new to react?

storedProducts = () => {
  axios.get('http://127.0.0.1:5000/product')
    .then(res => {
      const storedProducts = res.data;
      let tempProducts = [];
      storedProducts.forEach(item => {
        const singleItem = { ...item
        };
        tempProducts = [...tempProducts, singleItem];

      });
      this.setState(() => {
        return {
          products: tempProducts
        };
      });
    })
}

Answer

In each iteration the current item of the storedProduct is cloned into a new object (singeItem). In the next line this singleItem is appended to a new array that is reassigend to tempProducts. tempProducts is a complete new array object created using the spread operator.