React js Item count after fetch returning strange response

I am trying to get data from server in react. Data fetching is ok and returning data as expected. There are duplicate items in the data. I want to get number of similar items as count. I have got a routine from internet it is saving data correctly in a array. But when I am trying to get only the count element of the object. In console log it is showing only an opening bracket. Why?

fetch("http://localhost:55663")
        .then((response) => response.json())
        .then((data) => {
          setItems(data);     

      const countsByCs = {};
          data.forEach(({ ItemId }) => {
            countsByCs[ItemId] = (countsByCs[ItemId] || 0) + 1;
          });
          const finalArray = Object.entries(countsByItem)
          .map(([ItemId, count]) => ({ ItemId, count }))
          .sort((a, b) => b.count - a.count);
          setItemCount(JSON.stringify(finalArray));


    console.log(items[0])



result= [