How to build a REACT FORM to post an object like this at once to the backend server?

{
  accountDetail: {
    accountStatus: "",
    referralCode: "",
    signUpRemarks: "",
    adminRemarks: "",
    accountStatusRemarks: ""
  },
  address: {
    latLong: {
      latitude: 0,
      longitude: 0
    },
    locality: {
      city: {
        district: {
          id: 55,
          state: {
            id: ""
          }
        },
        id: 1683
      },
      id: 9
    },
    street: ""
  },
  businessDetail: {
    businessName: "",
    gstRegistered: true,
    gstin: ""
  },
}

PLEASE HELP

I would flatten the data and rebuild it on the backend.

E.g.

locality: {
      city: {
        district: {
          id: 55,
        },
      },
    },

becomes locality_city_district_id: 55

Can please help me with the code? Please… please

What part of @miku86’s suggestion do you not understand? See if you can implement it yourself and if you get stuck, post the code you tried. This is how we learn.

1 Like