Guilherme1 | 2023-06-27 20:59:52 UTC | #1
Hi, Im having trouble to get PureCloudRegionHosts property. I'm importing 'purecloud-platform-client-v2' inside my TypeScript project this way:
import platformClient = require("purecloud-platform-client-v2")
const client = platformClient.ApiClient.instance
Following the Integration Open example, I have this code:
client.setEnvironment(platformClient.PureCloudRegionHosts.us_east_1) // Genesys Cloud region
// Manually set auth token or use loginImplicitGrant(...) or loginClientCredentialsGrant(...)
client.setAccessToken("your_access_token");
But when I try access the PureCloud RegionHosts property, i got this error message:
Property 'PureCloudRegionHosts' does not exist on type 'typeof import("C:/Users/Guilherme/Desktop/2bebot/GenesysService/typescriptrest-express/nodemodules/purecloud-platform-client-v2/index")
tim.smith | 2023-06-27 21:06:44 UTC | #2
Guilherme1, post:1, topic:20725
import platformClient = require("purecloud-platform-client-v2")
I don't believe that's a valid statement. It appears you're working in a CommonJS (node) environment, so try the example here: https://developer.genesys.cloud/devapps/sdk/javascript#commonjs
// Obtain a reference to the platformClient object
const platformClient = require('purecloud-platform-client-v2');
If you're working in an ES6+ environment and meant to use import instead of require, refer to this blog post and project for an example: https://developer.genesys.cloud/blueprints/react-app-with-genesys-cloud-sdk/.
Guilherme1 | 2023-06-27 21:10:26 UTC | #3
im using CommonJS module... I tried use two forms
import platformClient = require("purecloud-platform-client-v2")
and
import platformClient from "purecloud-platform-client-v2"
The same problem occurs
tim.smith | 2023-06-28 12:09:58 UTC | #4
Can you try the format in the example above that's copied from the docs or the one in the blog?
system | 2023-07-29 12:10:44 UTC | #5
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 20725