I am using an API which is returning results in a format that includes extra nodes. I want to recursively run through the results to remove the "data" nodes so that I can use it in my application.
Can I do this with plain javascript or Lodash?
This is the results that I am getting:
"pages": {
"data": [
{
"id": 32,
"pages": {
"data": [
{
"id": 33,
"pages": {
"data": []
}
},
{
"id": 34,
"pages": {
"data": [
{
"id": 35,
"pages": {
"data": []
}
}
]
}
}
]
}
},
{
"id": 36,
"pages": {
"data": []
}
}
]
This is what I would like to have returned:
"pages": [
{
"id": 32,
"pages": [
{
"id": 33,
"pages": []
},
{
"id": 34,
"pages": [
{
"id": 35,
"pages": []
}
]
}
]
},
{
"id": 36,
"pages": []
}
]