Cannot extract JSON property from object

I have this code

request(options, (error, response) => {
  const data = JSON.parse(response.body)
  //console.log( JSON.stringify(data, null, " ") );

Which gives me this output

 result: 'OK',
 data: {
   body: {
     pdpHeader: [Object],
     overview: [Object],
     hotelWelcomeRewards: [Object],
     propertyDescription: [Object],
     guestReviews: [Object],
     atAGlance: [Object],
     hotelBadge: [Object],
     unavailable: {}
  common: { pointOfSale: [Object], tracking: [Object] }
  transportation: { transportLocations: [ [Object], [Object], [Object] ] },
  neighborhood: { neighborhoodName: 'Manhattan' }

Within the actual body of this output there is this:

{4 items
"data":{2 items
    "body":{14 items
        "pdpHeader":{6 items

I want to call out the hotelID number: 424023

I have tried the following a few other modifications to this, but cannot seem to call out the correct object


But I get the error message


TypeError: Cannot read property 'pdpHeader' of undefined


You’ve called your const data as well, so you’ll either need to destruct or call .data again, like so.


You can destruct the propery onto your data const like so:

const { data } = JSON.parse(response.body)
// data.body.pdpHeader.hotelID


If you don’t want to destruct, call as per below.

const data = JSON.parse(response.body)

Source: stackoverflow