This is my object:
{
"user": {
"id": 11,
"name": null,
"email": null,
"phone": "000000000",
"age": null,
"role": "user",
"otp": "656440",
"otpCreatedAt": null,
"createdAt": "2020-10-24T07:38:54.000Z",
"updatedAt": "2020-10-24T07:38:54.000Z"
}
}
Am getting this from querying on mysql db, now i dont want to send all the values to response ! Instead i need selected values to be sent under a single key !
Expected output
{
"user" :{
"name": null,
"email": null,
"phone": "000000000",
"age": null,
}
}
I can split this and send like name: user.name
etc but i need all the needed under single key !
How to achieve this ?
As of now am just splitting it like this !
phone: user.phone, name: user.name, age: user.age, email: user.email