Broadleaf Microservices
  • v1.0.0-latest-prod

Sandbox

In this section of the documentation we look at the menu functionality exposed by the CommerceSDK. This is mostly concerned with validated Preview-on-Site tokens. Preview-on-Site functionality allows admin user to preview what their changes will look like on the commerce-facing site before the changes go live. In order to see non-deployed changes, a special auth token is generated and the user is redirected from the admin to the storefront. The storefront app then needs to validate the token before updating the preview header in requests to other APIs.

Table of Contents

Setup the client

Before you can make a request using the SandboxClient, you’ll need to import the client and create a new instance. An example of this setup is as follows:

Example of creating a MenuClient instance
import { SandboxClient } from '@broadleaf/commerce-sandbox';

const APPLICATION_TOKEN = `${YOUR_APPLICATION_TOKEN}`; (1)
const BASE_HOST = `${YOUR_PUBLIC_BASE_URL}`; (2)

export const sandboxClient = new SandboxClient({
  applicationToken: APPLICATION_TOKEN,
  baseHost: BASE_HOST
});
  1. This is the unique "Application Token" for your store. You can find this by logging into your instance and looking at the application’s properties page.

  2. This is the base URL for your application (i.e. https://demo123.broadleafcommerce.org)