Back to Content Management API

blogByHandle

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

Arguments

  • Name
    handle
    Type
    String!
    Description

    The handle of the blog.

  • Name
    version
    Type
    Version
    Description

    The state of the blog you want to retrieve.

    • To get the latest content use CURRENT.
    • To get the latest published content use PUBLISHED

Returns

  • Name
    Blog*
    Type
    Blog
    Description

    Any requested field from the Blog object.

Request

import { PackClient } from '@pack/client'
const packClient = new PackClient({
  token: 'YOUR-PACK-TOKEN'
});

const query = `
query BlogByHandle($handle: String!, $version: Version) {
  blogByHandle(handle: $handle, version: $version) {
    title
    handle
    description
  }
}
`
const variables = {
  handle: "blog-handle",
  version: "CURRENT"
}
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

{
  "data": {
      "blogByHandle": {
          "title": "Blog Title",
          "handle": "blog-handle",
          "description": "Blog Description"
      }
  }
}

Was this page helpful?