What is the proper way to interact with AdminAPI within a headless Shopify Hydrogren store front? What I would like to do is interact with the Admin API to manipulate pricing and create draft orders (bundles). I do have a custom app set up in my Shopify Admin and have keys and scopes are set correctly. I’m not seeing any tutorials/guides on this process to interact with a different API within this environment and want to make sure I follow standards vs. hacking my way through it.
Thanks
hank
I think I figured it out:
https://www.npmjs.com/package/@shopify/admin-api-client
npm install /admin-api-client -s
import {createAdminApiClient} from '@shopify/admin-api-client';
const client = createAdminApiClient({
storeDomain: 'your-shop-name.myshopify.com',
apiVersion: '2023-04',
accessToken: 'your-admin-api-access-token',
});
Well… I thought I figured it out. When I go this direction on my dev store that is on Hydrogen I get:
An unexpected error occurred
Commenting out
import {createAdminApiClient} from '@shopify/admin-api-client';
const client = createAdminApiClient({
storeDomain: env.PUBLIC_STORE_DOMAIN,
apiVersion: env.LATEST_API_VERSION,
accessToken: env.SHOPIFY_API_TOKEN,
})
Gets the site back. This code works for my local dev. So the question is still there, what is the proper way to call and use Admin API?
Thanks again!