I am building one nodejs application where in req.body:
I have this object:
{
"id": 8,
"username": "sameer",
"age": "20"
"details": [
{
"category": {
"id": 1,
"nickname": "sam"
}
},
{
"category": {
"id": 2,
"nickname": "basha"
}
}
]
}
My expected output:
{
"id": 8,
"username": "sameer",
"age" : "20",
"final": [1,2] // this id coming from category id.
}
I tried this static way:
var data = 'myJsonStuffs'
var result = data.details.map(x => {
return({
"id": data.id,
"username": data.username,
"age": data.age,
"final": [1,2] // i want this dynamic
});
});
console.log(result);
How to do this using map? is this possible to return dynamic values.