title: js: TypeError: Cannot read property 'replace' of undefined using
body: <p>I wanted to replace <code>/\r?\n|\r/g</code> with empty string but got a type error &quot;Cannot read property 'replace' of undefined&quot;.</p>
  <pre><code>export function getCupsCredentials() {
      var vcap_services = process.env.VCAP_SERVICES;
      var vcap_servces_as_single_line = vcap_services.replace(/\r?\n|\r/g, &quot; &quot;);
      var vcap_servces_as_json = JSON.parse(vcap_servces_as_single_line)
      var vcap_servces_user_provided = vcap_servces_as_json['user-provided']
      var cups_credentials = vcap_servces_user_provided[0].credentials;
      return cups_credentials;
  }
  </code></pre>
  <p>i got the following error message on using .replace</p>
  <pre><code>TypeError: Cannot read property 'replace' of undefined
  at getCupsCredentials (/app/ui/dist/webpack:/src/utils/VcapUtils.js:4:50)
  at Object.defineProperty.value (/app/ui/dist/webpack:/src/utils/IAMUtils.js:5:17)
  at __webpack_require__ (/app/ui/dist/webpack:/webpack/bootstrap 713b700ecf31:19:1)
  at Object.defineProperty.value (/app/ui/dist/webpack:/src/api/middleware/filters/authFilter.js:1:1)
  at __webpack_require__ (/app/ui/dist/webpack:/webpack/bootstrap 713b700ece831:19:1)
  at Object.&lt;anonymous&gt; (/app/ui/dist/webpack:/src/api/middleware/pre.js:1:1)
  at __webpack_require__ (/app/ui/dist/webpack:/webpack/bootstrap 713b70031:19:1)
  at Object.defineProperty.value (/app/ui/dist/webpack:/src/api/middleware/index.js:1:1)
  at __webpack_require__ (/app/ui/dist/webpack:/webpack/bootstrap 713b700ececf31:19:1)
  at Object.canUseDOM (/app/ui/dist/webpack:/src/server.js:4:1)
  Starting Conductor UI
  using Conductor API server from 'http://chand-wf-nfce-server.cloud.pcftest.com/api'
   
  /app/ui/dist/webpack:/src/utils/VcapUtils.js:4
  var vcap_servces_as_single_line = vcap_services.replace(/\r?\n|\r/g, &quot; &quot;);
  </code></pre>