Back to Content Management API

pageByHandle

Returns a page by hande in a draft or published state.

Arguments

  • Name
    handle
    Type
    String!
    Description

    The handle of the page.

  • Name
    version
    Type
    Version
    Description

    The state of the page you want to retrieve.

    • To get the latest content use CURRENT.
    • To get the latest published content use PUBLISHED
  • Name
    country
    Type
    CountryCode
    Description

    The country context for the query. Used with the @inContext directive.

  • Name
    language
    Type
    LanguageCode
    Description

    The language context for the query. Used with the @inContext directive.

Returns

  • Name
    Page*
    Type
    Page
    Description

    Any requested field from the page object.

Request

import { PackClient } from '@pack/client'
const packClient = new PackClient({
  token: 'YOUR-PACK-TOKEN'
});
const query = `
query pageByHandle($handle: String!) {
  pageByHandle(handle: $handle) {
    id
    title
  }
}
`;
const response = await packClient.fetch(query, { variables: { handle: 'your-page-handle' } });
console.log(response.data);

Response

{
    "data": {
        "pageByHandle": {
            "id": "your-page-id",
            "title": "your-page-title"
        }
    }
}

Was this page helpful?