Hook context

The hook context is a parameter of the hook function which contains information about the hook's environment.

Supported context properties:

isTestMode: boolean Determines whether the hook is run in test mode
shopifyDomain: string The domain of the store

As an example, different API endpoints can be used based on run mode:

module.exports = async function (payload, actions, context) {
  const api = context.isTestMode ? 
                'https://dev.myapi.com' : 
                'https://myapi.com';

  const { data } = await actions.http.post(api, { a: 1 });
}