Order-Ahead Sample Application - Could not get Base URL

Hi,

I am following the tutorial for testing the node.js order API however, I am getting this error

Could not get Base URL. Invalid environment or server.
Error: Could not get Base URL. Invalid environment or server.
at getBaseUri (…\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:19886:9)
at DefaultRequestBuilder._baseUrlProvider (…\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:19787:14)
at DefaultRequestBuilder.toRequest (…\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:19250:27)
at DefaultRequestBuilder._callee3$ (…\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:19404:36)
at tryCatch (…\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:275:40)
at Generator.invoke [as _invoke] (…\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:505:22)
at Generator.next (…\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:330:21)
at asyncGeneratorStep (…\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:16:24)
at _next (…\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:38:9)
at …\connect-api-examples\connect-examples\v2\node_orders-payments\node_modules\square\dist\square.cjs.development.js:45:7

I ran npm install and npm test after setting up my credentials in the .env file and changing the test key of the script object in package.json from NODE_ENV=sandbox nodemon -e js,pug ./bin/www to SET NODE_ENV=sandbox & nodemon -e js,pug ./bin/www

Please help.

Hi @toonday, welcome to the forums!

This sounds like you set the wrong environment (not production or sandbox). See here: https://github.com/square/square-nodejs-sdk/blob/master/src/client.ts#L173. Can you share code snippet of how you’re creating the client (without access tokens)?

@sjosey you are right and I was able to resolve this. The issue was the space after sandbox in this command SET NODE_ENV=sandbox & nodemon -e js,pug ./bin/www once I changed this to SET NODE_ENV=sandbox&nodemon -e js,pug ./bin/www everything worked fine.

1 Like

@sjosey I posted another question regarding the ability to use the orders API to support in-person payments at a Square POS (either via Card or Cash) because it seems the APIs only currently support pre-paid card payments online.