Back to Content Management API
blog
Returns a blog by ID in a draft or published state.
Arguments
- Name
id
- Type
- ID!
- Description
The ID 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
- To get the latest content use
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 Blog($id: ID!, $version: Version) {
blog(id: $id, version: $version) {
title
handle
description
}
}
`
const variables = {
id: 'blog-id',
version: "CURRENT"
}
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"blog": {
"title": "Blog Title",
"handle": "blog-handle",
"description": "Blog Description"
}
}
}