I am trying to fetch data from the JSON object by using Object.values
so my JSON looks like this
const jsonValue=
[
{
files:{
title:{
"en": "test"
}
,
description:{
"en": "dummy description"
}
}
},
{
files:{
title:{
"eu": "without description"
}
}
},
];
jsonValue.map((data)=>{
const des =Object.values(Object.values(data)[0]?.description)?? "";
console.log(...des)
})
I am trying to fetch the description value and if the description key is not present then it should return a blank space
I am using Object.values because en
, and eu
values get changed every time so to overcome this I am using Object.values
but it showing me an error cannot convert undefined.
My expected output is I want to fetch the description value if it presents inside the JSON and return a blank space if it is not present in JSON