Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

Promise data not returned on device

$
0
0

@JimboJ wrote:

Hi all, I've been pulling my hair out for the last week over this bug so I'm really hoping someone will be able to tell me where I'm going wrong.

I have a ionic app, I'm using PouchDB with the SQLlite cordova plugin. When the app loads if there is any existing data in local storage I'm grabbing it and adding it to PouchDB. This works fine in a desktop browser (Chrome and Safari) and also in the iOS simulator BUT not on a device....

Here's the code that's failing:

PouchdbFactory.updateCodes(oldCodesArray).then(function() { // <-- this works, it updates the pouchDB with a reformed array of the old localstorage data

        PouchdbFactory.getAllCodes().then(function(codes) { // Codes is always empty when on the device, but contains all the data in pouchDB when ran in the ios simulator or on desktop chrome/safari
            $scope.codes = codes;
            $rootScope.$emit('codesUpdated', codes);
            $localstorage.removeObject('codes');
        }).catch(function(error) {
            console.log(error); // I don't get any errors on device
        });
});

In case you missed the comments in the code, getAllCodes() should return all the data in the the PouchDB (which it does on the ios simulator and on desktop chrome ad safari) however, codes is always empty when ran on device...

At first I thought this was a pouchDB issue but this only happens when deployed on a device (the data is added to PouchDB fune but the returned codes from getAllCodes() is always empty...

Please can someone help and stop me from getting the noose out...

Thanks in advance!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>