I have the following array of objects:
const pages = [
{
posts: {
pageInfo: {
hasNextPage: true
},
edges: [
{ id: 1 },
{ id: 2 }
]
}
},
{
posts: {
pageInfo: {
hasNextPage: true
},
edges: [
{ id: 3 },
{ id: 4 }
]
}
},
]
I need to keep only the content of the edges
subarrays, like this:
const postsOnly = [
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 }
]
Closest I've come is:
const postsOnly = pages.map( ( { posts } ) => posts.edges )
But this leaves me with a subarray for every original posts
object, like this:
const postsOnly = [
[
{ id: 1 },
{ id: 2 }
],
[
{ id: 3 },
{ id: 4 }
]
]
How can I delete these subarrays but keep their contents?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…