I am trying to access a array inside json object. This is my json file.
{
"items": [
{
"createTime": "2019-10-25T04:33:50.238Z",
"attachments": [
{
"name": "xxx.pdf",
"legal": false,
"id": "1908925450",
"abc": true,
"def": true
},
{
"name": "xxx_original.xml",
"legal": true,
"id": "1908925449",
"abc": false,
"def": false
}
]
}
]
}
I access the details contains here using following code
const {
items = [],
attachmentList = items.slice(0, 1).map(item => item.attachments),
attachmentName = attachmentList.slice(0, 1).map(item => item.name),
createTime = items.slice(0, 1).map(item => item.createTime),
} = data;
I can get the value for createTime, but I cannot get attachmentName, it returns empty ? Why it is not possible to get values from attachments