JSFiddle - React, Tailwind, and code Playground

by John Wick

JavaScript

/* const obj1 = {key1: 1, key2: 2};
const obj2 = {key4: 4, key6: 6};

const newVal = {...obj1, ...obj2 };

console.log(newVal);
 */
 
const options = {
 "agent": {
  "firstName": "aaa",
  "lastName": "aaa",
  "phoneNumber": "",
  "userId": ""
 }
}
const applicationData = {
  "id": "b5904de0-4e84-46bf-8109-ec5e44a94174",
  "lineOfBusiness": "PERSONAL",
  "isActive": true,
  "status": "none",
  "applicantId": "1560c280-56f7-42b8-87bb-5672659f4dc3",
  "createdAt": "2023-05-12T13:00:36.049Z",
  "updatedAt": "2023-05-12T13:02:43.296Z",
  "integrations": null,
  "selections": null,
  "metadata": {
    "revenuePartnerId": "a031b000002YnOeAAK",
    "affiliateDataId": "6bd654d2-05cc-4516-b805-8e45d3da61fd",
    "googleAnalyticsUserId": "2fae36e4-d5c6-472a-ab56-365c4071a7d6",
    "product": "HOME",
    "source": "MindOfMyloBuyflows",
    "bundle": "false",
    "useDataPrefill": "false",
    "browserDetails": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
    "fullUrl": "http://localhost:8080/pl/home/mind-of-mylo/quote#/insurance/home-insurance",
    "tcpaOptInAgreementCopy": "By clicking the button below, I give my electronic signature and consent to be called by Mylo or receive text messages at this number regarding my inquiry.\nThis consent is not required for purchase and can be revoked at any time. My telephone company may impose additional charges for text messages.",
    "tcpaOrigin": "HOMEBuyflow",
    "ipAddress": "::1"
  },
  "dynamicQuestionAnswers": []
}

/* console.log('applicationData:', applicationData);
console.log('opts:', opts);
 */
 
const updatedAppData = Object.assign({}, applicationData, {
  metadata: {
    ...applicationData.metadata,
    agent: options.agent
  }
})

console.log('updatedAppData:', updatedAppData);