From a22f773dc0d52f29cc496b544731a3068fe7ded6 Mon Sep 17 00:00:00 2001 From: Ali Tahir Date: Mon, 3 Feb 2020 14:12:39 -0500 Subject: [PATCH] fixed issue with process not being available in web environment. --- package.json | 2 +- src/api-client.js | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 72b852e..01581f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@agility/content-fetch", - "version": "0.8.0", + "version": "0.8.1", "description": "JavaScript library for the Agility Fetch API (node and browser)", "main": "dist/agility-content-fetch.node.js", "scripts": { diff --git a/src/api-client.js b/src/api-client.js index e7efe58..a5dfeb3 100644 --- a/src/api-client.js +++ b/src/api-client.js @@ -28,19 +28,22 @@ const defaultConfig = { }; function buildEnvConfig() { - let env = process.env; let envConfig = {}; - if (env.hasOwnProperty('AGILITY_BASEURL')) { - envConfig.baseUrl = env.AGILITY_BASEURL; - } - if (env.hasOwnProperty('AGILITY_GUID')) { - envConfig.guid = env.AGILITY_GUID; - } - if (env.hasOwnProperty('AGILITY_APIKEY')) { - envConfig.apiKey = env.AGILITY_APIKEY; - } - if (env.hasOwnProperty('AGILITY_ISPREVIEW')){ - envConfig.isPreview = env.AGILITY_ISPREVIEW; + + if (process && process.env) { + let env = process.env; + if (env.hasOwnProperty('AGILITY_BASEURL')) { + envConfig.baseUrl = env.AGILITY_BASEURL; + } + if (env.hasOwnProperty('AGILITY_GUID')) { + envConfig.guid = env.AGILITY_GUID; + } + if (env.hasOwnProperty('AGILITY_APIKEY')) { + envConfig.apiKey = env.AGILITY_APIKEY; + } + if (env.hasOwnProperty('AGILITY_ISPREVIEW')){ + envConfig.isPreview = env.AGILITY_ISPREVIEW; + } } return envConfig;