Back to Content Management API
nodes
Returns content objects for a list of IDs. Each result can be a Page, ProductPage, CollectionPage, Article, Blog, Section, Template, or ContentRelease. Results are returned in the order of ids, with null for any ID that does not match.
Arguments
- Name
ids- Type
- [ID!]!
- Description
The IDs of the objects.
Returns
- Name
[Node]!- Type
- [Node]!
- Description
The matching objects, in the order requested.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN',
})
const query = `
query Nodes($ids: [ID!]!) {
nodes(ids: $ids) {
id
... on Page {
title
}
... on ContentRelease {
name
status
}
}
}
`
const variables = {
ids: [
'page-id',
'release-id',
'missing-id',
],
}
const response = await packClient.fetch(query, { variables })
console.log(response.data)
Response
{
"data": {
"nodes": [
{
"id": "page-id",
"title": "Home"
},
{
"id": "release-id",
"name": "Holiday launch",
"status": "open"
},
null
]
}
}