I am trying to initiate a call from a button click in the browser using the Twilio Voice JS SDK (v.2.1.1).
I have successfully created the voice object (this.voice), and when I run the code below, I am receiving an error in the browser console, "Cannot read properties of undefined (reading 'create')".
The code I'm using was demonstrated at https://www.twilio.com/docs/voice/tutorials/how-to-make-outbound-phone-calls/node.
NOTE: When I run this same code in the C# implementation, it works as expected.
Here is my code: @lizziepika, here are the applicable code snips related to this issue:
bindVoice() : void {
this.tcemsService.getVoiceCapabilityToken().toPromise().then
(
voiceToken => {
this.voice = new Twilio.Device( voiceToken.token, {
disableAudioContextSounds: true
} );
}
)
}
... then ...
_this.bindVoice();
_this.voice.create( {
twiml: '<Say>Connecting Call</Say>',
to: '+14071234567',
from: '+14079876543'
} );
When I set a breakpoint, _this.voice exists, but the method for create fails.