Back to Content Management API
node
Returns a content object by ID without knowing its type in advance. The result can be a Page, ProductPage, CollectionPage, Article, Blog, Section, Template, or ContentRelease. Use inline fragments to select type-specific fields.
Arguments
- Name
id- Type
- ID!
- Description
The ID of the object.
Returns
- Name
Node- Type
- Node
- Description
The matching object, or
nullwhen no object matches.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN',
})
const query = `
query Node($id: ID!) {
node(id: $id) {
id
... on Page {
title
handle
}
... on Section {
title
}
}
}
`
const variables = {
id: 'page-id',
}
const response = await packClient.fetch(query, { variables })
console.log(response.data)
Response
{
"data": {
"node": {
"id": "page-id",
"title": "Home",
"handle": "home"
}
}
}