ocilo / skype-http

Unofficial Skype API for Node.js via HTTP
https://ocilo.github.io/skype-http
MIT License
51 stars 24 forks source link

getContacts undefined #52

Closed James91 closed 6 years ago

James91 commented 6 years ago

I'm using Javascript and and I'm doing the following code

skypeHttp.connect(
        { credentials: {
            username: "**********",
            password: "***********"
        },
            verbose: true
        }).then(function(skypeAccount) {
            //var contacts = skypeHttp.Api.getContacts();
            var contacts = skypeAccount.Api.getContacts();
            response.send(200, JSON.stringify(contacts, null,2));
    }).catch(function(error) {
        var data = { error: "true", message: error.message};
        response.send(422,data);
    });

I get the following error

Cannot read property 'getContacts' of undefined

Am I doing something wrong?

demurgos commented 6 years ago

Hi,

The result of the skypeHttp.connect function is an instance of the Api associated to the account. You can call the methods immediately on it:


skypeHttp.connect(...)
  .then((api) => {
    return api.getContacts();
  })
  .then((contacts) => {
    console.log(contacts);
  })

In the source directory, there is an example using the async/await syntactical sugar: https://github.com/ocilo/skype-http/blob/master/src/example/main.ts#L55-L56.

It's been a long time since the maintenance of the library is pretty minimal. I still would like to work on this, during the previous year I worked on a library for schema verification (to be able to guarantee the returned values), and especially on project management. Last week I was able to set up continuous deployment of packages to npm and documentation generation + deployment to Github pages. The only missing thing is support for compilation with watch mode and it should be ready. I'll update this project to benefit from these updates and take a break to work on this library. (I noticed some issues with replying to messages 2 days ago.)

Sorry for the lack of time to work on this. Still, if you have other questions or even want to submit some changes I'd be happy to help.

James91 commented 6 years ago

Thank you for the quick reply. That sorted that issue. I like API. Thank you for building it