Jayhaco | 2024-04-01 10:42:29 UTC | #1
Hi,
I'm trying to build a angular application. I installed and import purecloud-platform-client-v2 package with version 191.0.0
However, I got the an error on:
ERROR TypeError: Cannot read properties of undefined (reading 'instance')
I create a function
private loginClient() {
const clientConfig = {
clientId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
clientSecret: 'yyyyyyyyyyyyyyyyyyyyyyyy',
redirectUri: 'http://localhost:4200/'
}
const client = platformClient.ApiClient.instance;
client.loginClientCredentialsGrant(clientConfig.clientId, clientConfig.clientSecret)
.then(() => {
// Do authenticated things
})
.catch((err) => {
// Handle failure response
console.log(err);
});
}
where the import is
import * as platformClient from 'purecloud-platform-client-v2';
I have noticed that platformClient is an empty object and therefore platformClient.ApiClient is null.
Jayhaco | 2024-04-03 05:59:24 UTC | #2
After checking the forum I found the problem, this is because Webpack looks at the purecloud-platform-client-v2 package.json, and uses the value in the browser field, which points to dist/web-cjs/purecloud-platform-client-v2.min.js. However, what is really needed is the ES6 entry point in src/purecloud-platform-client-v2.
https://developer.genesys.cloud/forum/t/how-to-add-purecloud-sdk-to-angular-12/12948
system | 2024-05-04 06:00:18 UTC | #3
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: 25492