0

I am getting data from an Object type from my database but the nested data inside the Object type is undeclared since its just a normal Object interface. So the task is that I must get the data from within this Object and put all of the data on the same level for instance:

contactDetails: Object; // this is how it is set in my class

//this is how i get it from the db
{
"contactDetails": {
        "firstName": "John",
        "lastName": "Doe",
        "email": "jd@email.com",
        "phoneNumber": "0123456789"
      },
"clientAccountNumber": "test1234"
}

and how it should look is like as following:

"newObject":{
    "firstName": "John",
    "lastName": "Doe",
    "email": "jd@email.com",
    "phoneNumber": "0123456789"
    "clientAccountNumber": "test1234"
}

The part I am struggling with is I don't know how to get that specific data from contactDetails for example contactDetails.firstName won't work and valueOf() also gives me issues. Any suggestions or help is appreciated

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
JägerKS
  • 3
  • 4
  • If your variable referring to that object is `clientDetails`, then you'd access `firstName` like this: `clientDetails.clientDetails.firstName` since `firstName` is inside an object assigned to the `clientDetails` property of the object. (You might want a different name for that variable.) – T.J. Crowder May 14 '21 at 07:50
  • 1
    @T.J.Crowder thanks for sending me to the right question got my answer there :D once again thanks a mil – JägerKS May 14 '21 at 08:05

0 Answers0