'angular 13 and twilio sync. TypeError variablename is not a constructor
a note. When I was using angular 10 this was working fine. Only after I upgraded to angular 13 did this become a problem.
require is put in constructor as this is a Injectable service and I believe that requires it to be in the contstructor.
notice the code in my TwilioSyncService
export class TwilioSyncService{
constructor(private http: HttpClient, private router: Router){
//@ts-ignore
this.syncClientclass = require('twilio-sync');
}
syncClientclass;
syncClient;
which is later used in code:
connect(token){
this.syncClient = new this.syncClientclass(token);
this.sendSyncClient(this.syncClient);
}
the Twilio sync documentation says this is correct
var SyncClient = require('twilio-sync');
var syncClient = new SyncClient(token);
from the docs linked below.
https://media.twiliocdn.com/sdk/js/sync/releases/3.0.1/docs/index.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
