@backpackjs/client
v0.0.1
Published
Pack client for interacting with the Pack GraphQL API
Downloads
2
Maintainers
Keywords
Readme
@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
# install dependencies
yarn
# build package
yarn build
# test package
yarn test