How to merge data elements and datastore payload using React JS

let self = this;
    await getPrograms().then((response) => {
      self.setState({
        dataElements : response.data.programs[0].programStages[0].programStageDataElements       
      }); 
    }).catch(error => this.setState({error: true}));

    await getDataStoreNameSpace(this.props.orgUnitId).then((response) => {
      self.setState({
        dataStoreNamespace : response.data.elements      
      }); 
    }).catch(error => this.setState({error: true}));

    // Merge two array
    const mergeById = (jsonPayload1, jsonPayload2) =>
    jsonPayload1.map(itm => ({
        ...jsonPayload2.find((item) => (item.id === itm.dataElement.id) && item),
        ...itm
    }));
    let mergedArray = mergeById(this.state.dataElements, this.state.dataStoreNamespace);
    this.setState({mergedArrayData: mergedArray});