1

I am new to React and I searched examples for this questions but I could not achieve to do this.

I make 2 separate calls to backend and getting 2 different dto and I want to put them into one table data instead of 2 separate ones.

Here is my code:

const [lensTableData, setLensTableData] = useState<InternalDTO>();
    const [dbsaTableData, setDbsaTableData] = useState<InternalDTO>();
    
useEffect(() => {
        context.services.adapterStatus.getLensAdapterStatus()
            .then((resp) => setLensTableData(resp));

        context.services.adapterStatus.getDbsaAdapterStatus()
            .then((resp) => setDbsaTableData(resp));
    }, [])

It is working but what I want to do is to make just 1 array instead of 2 different and I want to add 2nd one into array after the first one. How can I combine them ?

abidinberkay
  • 1,857
  • 4
  • 36
  • 68
  • 1
    i somehow cannot answere this question, but try this: setDbsaTableData( [...dbsaTableData, ...resp] ) – jovan Feb 19 '22 at 17:21

0 Answers0