Back to Content Management API
productPageByHandle
Returns a product page by hande in a draft or published state.
Arguments
- Name
handle- Type
- String!
- Description
The handle of the product page.
- Name
version- Type
- Version
- Description
The state of the product page 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
- Name
draftId- Type
- ID
- Description
Legacy, from the drafts system that Content Releases replaced. To read or write a release's changes, send the
X-Pack-Release-Idheader instead. See Content Releases.
To get localized content, pass language and country to the @inContext directive on the query instead. See Localization.
Returns
- Name
ProductPage.*- Type
- ProductPage
- Description
Any requested field from the Productpage object.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN'
});
const query = `
query ProductPageByHandle($handle: String!) {
productPageByHandle(handle: $handle) {
title
handle
seo {
title
description
image
}
}
}
`;
const variables = {
handle: 'new-product',
}
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"productPageByHandle": {
"title": "Product Title",
"handle": "product-handle",
"seo": {
"title": "Product Title",
"description": "Product Description",
"image": "https://example.com/product.jpg"
}
}
}
}