PeterStaev / nativescript-azure-mobile-apps

:cloud: NativeScript plugin for working with Microsoft Azure Mobile Apps services
Apache License 2.0
30 stars 10 forks source link

TypeError: MobileServiceClient is not a constructor #29

Closed axprin closed 6 years ago

axprin commented 6 years ago

I'm trying to use this plugin to interface with an Azure db. As instructed in the documentation, I have configured the AndroidManifest.xml and app.gradle files correctly. My usage is as follows:

var MobileServiceClient = require("nativescript-azure-mobile-apps/client");

try {
    var client = new MobileServiceClient("****.database.windows.net");
} catch (error) {
    console.log("error with Azure stuff: ", error);
}

And I get the following in the console: JS: error with Azure stuff: TypeError: MobileServiceClient is not a constructor

PeterStaev commented 6 years ago

Hey @axprin , you are not importing the plugin correctly. It is best you use TypeScript or if you want to use JS to look at the transpiled files after you build the demo app so you can see how things are imported. In you case the import statement should be something like:

var MobileServiceClient = require("nativescript-azure-mobile-apps/client").MobileServiceClient;

Also I do not think the plugin will work if you connect it directly to Azure DB URL. As the name of the plugin says, it is meant to be used with the Azure Mobile Apps.

axprin commented 6 years ago

@PeterStaev Thank you!