Hi,
I was following the tutorial for Azure communication API.
https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/voice-video-calling/getting-started-with-calling?pivots=platform-web
My code is as follows,
import { CallClient, CallAgent } from "@azure/communication-calling";
import { AzureCommunicationUserCredential } from '@azure/communication-common';
let call;
let callAgent;
const { CommunicationIdentityClient } = require('@azure/communication-administration');
const connectionString = 'endpoint=...'; //Pasted valid connection string
let identityResponse = "";
// Instantiate the identity client
const identityClient = new CommunicationIdentityClient(connectionString);
async function init() {
identityResponse = await identityClient.createUser();
let tokenResponse = await identityClient.issueToken(identityResponse, ["voip"]);
const { token, expiresOn } = tokenResponse;
const callClient = new CallClient();
const tokenCredential = new AzureCommunicationUserCredential(tokenResponse.token);
callAgent = await callClient.createCallAgent(tokenCredential);
callButton.disabled = false;
}
init();
I have valid connection string as I have Communication service resource in Azure. But when NodeJS compiles the program, it produces the following error
![62465-image.png](https://learn-attachment.microsoft.com/api/attachments/62465-image.png?platform=QnA)
When I proceed to run the program, I receive the following error in browser console.
Uncaught (in promise) TypeError: _azure_communication_common__WEBPACK_IMPORTED_MODULE_1__.AzureCommunicationUserCredential is not a constructor
at init (client.js:26)
init @ client.js:26
async function (async)
init @ client.js:17
./client.js @ client.js:32
webpack_require @ bootstrap:19
0 @ log.js:59
webpack_require @ bootstrap:19
(anonymous) @ bootstrap:83
(anonymous) @ bootstrap:83
Please help me to find the root cause.