I have been experiencing inconsistency in data retrieval using javascriptAPI

Hi,
I have been experiencing inconsistency in data retrieval. The code bellow extracts people whom a particular user is following from the Follows table and the extracts their ID’s which will be used to extract their Posts from Timeline table.

function show(data) {
    var content  = '<h3>'+data.fullName+' <small style="float:right">'+timesAgoShort(data.createdAt)+'</small></h3>';
    content += '<p>'+data.content+' <em style="font-size:10px;">id :'+data.id+'<em></p>';
    $('body').append(content);
}



var getFollows = Backendless.Persistence.of( Follows );
var getTimeline = Backendless.Persistence.of( Timeline );



// Get All the people 'D6F3FFF9-A1AF-21F5-FF01-10883E85C500' is following
var promise = new Promise(function(resolve, reject) {

var query = new Backendless.DataQuery();

query.options = {relationsDepth:1, sortBy: "created"};
query.condition= "fromUser.objectId = 'D6F3FFF9-A1AF-21F5-FF01-10883E85C500'";




var result = getFollows.find(query);
var followingUsers = [];
for (var i = 0; i < result.data.length; i++) {
    if(result.data.toUser.objectId) {
        //Store the users being followed
       followingUsers.push({id : result.data.toUser.objectId, fullName : result.data.toUser.name});
   }
}



if (followingUsers.length) {
    resolve(followingUsers);
}
else {
    reject(Error("It broke"));
}
});



// Get All Posts of people, 'D6F3FFF9-A1AF-21F5-FF01-10883E85C500' is following
promise.then(function(followingUsers) {



var query = new Backendless.DataQuery();

var string = '';
for (var i = 0; i < followingUsers.length; i++) {
string += "fromUser.objectId = '"+followingUsers.id+"'";



if((followingUsers.length - 1) > i)
string += ' or ';
}
query.options = {relationsDepth:1, sortBy: "created desc"};
query.condition= string;
var timelineResults= getTimeline.find(query);



for (var i = 0; i < timelineResults.data.length; i++) {
 //Display the data in html format
show({id : timelineResults.data.fromUser.objectId, fullName : timelineResults.data.fromUser.name, content : timelineResults.data.content, createdAt : timelineResults.data.created });
}
 
}, function(err) {
console.log(err);
});

I run this code 3 out of 10 time i get the correct response. I am attaching screenshots
C:\Users\Admin\Downloads\Backendless-Screenshot-(Correct Data).png</img>

Hi Tabish,

Seems that sometimes relations are not loaded or missing. Are you sure you’re not doing anything else between these 10 calls? I mean, are you sure that they are totally identical?

Also, do you have any Event Handlers for Data Service?

Hi Sergey,

Thank you for the quick response.
The code during refresh was identical (untouched, unchanged) and i have not implemented any business logic. The only thing i did was press F5 on the browser .

Can you please provide your appId and secretKey here or send them to support@backendless.com, so that we can check and investigate this on your app?