Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class extends value undefined is not a constructor or null using library in Angular 7 #8

Open
drenda opened this issue Apr 29, 2019 · 0 comments

Comments

@drenda
Copy link

drenda commented Apr 29, 2019

Hi,
I'm trying to use the library into my Angular 7 project.

I created a service like this:

import {Injectable} from '@angular/core';
const AmiClient = require('asterisk-ami-client');

@Injectable()
export class AsteriskPbxService {
  client = new AmiClient();

  constructor() {
  }

  start(){
    this.client.connect('manager', 'xxxxxxx', {host: 'localhost', port: 5038})
        .then(amiConnection => {

          this.client
              .on('connect', () => console.log('connect'))
              .on('event', event => console.log(event))
              .on('data', chunk => console.log(chunk))
              .on('response', response => console.log(response))
              .on('disconnect', () => console.log('disconnect'))
              .on('reconnection', () => console.log('reconnection'))
              .on('internalError', error => console.log(error))
              .action({
                Action: 'Ping'
              });

          setTimeout(() => {
            this.client.disconnect();
          }, 5000);

        })
        .catch(error => console.log(error));
  }

  
  destroy() {
  if(this.client){
     this.client.disconnect();
   }
  }
}

I added it to my providers. Unfortunately when the project starts I've this error:

AmiEventsStream.js:16 Uncaught TypeError: Class extends value undefined is not a constructor or null
    at Object../node_modules/asterisk-ami-events-stream/lib/AmiEventsStream.js (AmiEventsStream.js:16)
    at __webpack_require__ (bootstrap:83)
    at Object../node_modules/asterisk-ami-connector/lib/AmiConnection.js (AmiConnection.js:10)
    at __webpack_require__ (bootstrap:83)
    at Object../node_modules/asterisk-ami-connector/lib/index.js (index.js:11)
    at __webpack_require__ (bootstrap:83)
    at Object../node_modules/asterisk-ami-client/lib/AmiClient.js (AmiClient.js:10)
    at __webpack_require__ (bootstrap:83)
    at Module../src/app/_service/pbx/asteriskPbx.service.ts (asteriskPbx.service.ts:2)
    at __webpack_require__ (bootstrap:83)

Am I doing something wrong? Do I need something to make the library work in Angular 7?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant