Back to Content Management API

article

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

Arguments

  • Name
    id
    Type
    ID!
    Description

    The ID 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 GetArticle($id: ID!, $version: Version) {
  article(id: $id, version: $version) {
    title
    handle
    description
  }
}
`

const variables = {
  id: "article-id",
  version: "CURRENT"
}
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

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

Was this page helpful?