Back to Content Management API
section
Returns a section by ID in a draft or published state.
Arguments
- Name
id
- Type
- ID!
- Description
The ID of the section.
- Name
version
- Type
- Version
- Description
The state of the section you want to retrieve.
- To get the latest content use
CURRENT
. - To get the latest published content use
PUBLISHED
- To get the latest content use
Returns
- Name
Section.*
- Type
- Section
- Description
Any requested field from the Section object.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN'
});
const query = `
query GetSection($id: ID!, $version: Version) {
section(id: $id, version: $version) {
title
handle
description
}
}
`
const variables = {
id: 'section-id',
}
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"section": {
"title": "Section Title",
"handle": "section-title",
"description": "Section Description"
}
}
}