@pack/client
The @pack/client
package provides a client for interacting with the Pack GraphQL API.
Installation
npm install @pack/client
Usage
The client needs to be configured with your store's token, which can be found in the Pack admin under Settings > Developer > API Keys.
import { PackClient } from '@pack/client';
const packClient = new PackClient({
token: 'YOUR_TOKEN',
contentEnvironment: 'production'
});
const { data, error } = await packClient.fetch(QUERY, OPTIONS);
- QUERY - The GraphQL query string
- OPTIONS - Optional
PackFetchOptions
variables
- Object containing any GraphQL variables
Returns a promise resolving to:
data
- The data returned by the GraphQL APIerror
- Any error that occurred, with additional info
Development
yarn
yarn build
yarn test