Step 2: Configure the Order-Ahead Sample Application

Download the order-ahead sample application from GitHub and complete the following steps to configure the sample application for your environment.

  1. Download the order-ahead sample application from GitHub.

  2. In the root directory of the sample, create a copy of the .env.example file and name the new file .env.

  3. In the .env file, replace the placeholder SQUARE_SANDBOX_ACCESS_TOKEN and SQUARE_SANDBOX_APPLICATION_ID values with the Sandbox credentials that you copied in Step 1: Get Developer Credentials.

    The following shows an example of new values:

    # Sandbox Credentials SQUARE_ACCESS_TOKEN=GmbHQbFdRGhiYCNp8sxVzdcfwhXPEi6KU-qbZohsWQeBC55iGHq5TB6Msexample SQUARE_APPLICATION_ID=sandbox-sq0idb-ueuyW79WprkFzwXexample ...

    You can optionally set your production credentials; however, you work in the Square Sandbox for the rest of this tutorial.

    Important

    You should use your own credentials only for testing the sample application. If you plan to make a version of this sample application available for your own purposes, use the OAuth API to securely obtain and manage access to Square accounts.

Link to section

Test your credentials

When you've finished setting up your credentials, you can test the order-ahead sample application to confirm that you've authorized your application.

To test the order-ahead sample application:

  1. Run the following command in the root directory of the order-ahead sample application:

    npm test
  2. Open localhost:3000 in your browser. If your sample application is set, you should see a gray screen with your business location name at the top.

    Did you know?

    Don't worry if you see the following error message: "Cannot read property ‘image_data’ of undefined." You work on importing catalog items in Step 3: Generate Test Catalog Items.