Search code examples
javascripthtmlwebstormsrckinvey

Using kinvey web with WebStorm IDE


Hello everyone I would just like to announce that I have little experience building web projects and that this is my first time using a service like kinvey on a web app.

I have been trying to follow the quick start guide for kinvey and seem to have gotten stuck on the first step. When (attempting to) integrate kinvey into my app using WebStorm it cant seems to find the files or something but doesn't end up executing the script tag. I can even download the files separately and tried to run that file but it doesn't work. A normal script tag works fine.

Could someone more experienced with this tell me what I am doing wrong? Here is the code I copied of the quick start guide.

<script src='//da189i1jfloii.cloudfront.net/js/kinvey-html5-1.6.8.min.js'>
    console.log("attemping to connect to kinvey")
    var promise = Kinvey.init({ appKey    : 'XXXXXXXXX', appSecret : 'XXXXXXXXXX'});
    promise.then(function(activeUser) {
        console.log("Connected to kinvey");
    }, function(error) {
        console.log("Error connecting to kinvey");
    });

    var promise = Kinvey.ping();
    promise.then(function(response) {
        console.log('Kinvey Ping Success. Kinvey Service is alive, version: ' + response.version + ', response: ' + response.kinvey);
    }, function(error) {
        console.log('Kinvey Ping Failed. Response: ' + error.description);
    });

</script>

Solution

  • After playing around with kinvey I found this (very simple) solution. I had simply needed to put the src call in a separate script tag my final code is like this (js/kinvey.js) is the downloaded kinvey files.

    <script src="js/kinvey.js"></script>
    <script>
        console.log("attemping to connect to kinvey")
        var promise = Kinvey.init({ appKey : 'XXXXXXXXXX', appSecret : 'XXXXXXXXXXXXXXX'});
        promise.then(function(activeUser) {
            console.log("Connected to kinvey");
            var promise2 = Kinvey.ping();
            promise2.then(function(response) {
                console.log('Kinvey Ping Success. Kinvey Service is alive, version: ' + response.version + ', response: ' + response.kinvey);
            }, function(error) {
                console.log('Kinvey Ping Failed. Response: ' + error.description);
            });
        }, function(error) {
            console.log("Error connecting to kinvey");
        });