Back to Content Management API

articleByHandle

Returns an article by hande in a draft or published state.

Arguments

  • Name
    handle
    Type
    String!
    Description

    The handle of the article.

  • Name
    version
    Type
    Version
    Description

    The state of the article you want to retrieve.

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

Returns

  • Name
    Article*
    Type
    Article
    Description

    Any requested field from the Article object.

Request

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

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

Response

{
  "data": {
    "articleByHandle": {
        "title": "Article Title",
        "handle": "article-handle",
        "description": "Article description."
    }
  }
}

Was this page helpful?