kis vukk
Posts: 0
Joined: Tue Oct 07, 2014 12:49 pm

Get response object data outside from mapping area

Hi

I try to get some data from a dataservice object without mappig.

In startScreen Load function use js command: window.dataserviceSetting.execute();

I want to get back respons data

In console log:
console.log(dataserviceSetting);
This shows all data:

_requestOptions: Object
options: Object
request: Object
response: Object
body: Object
versions: Array[1]

"versions" array content all data what i wan to get from my website mysql database.
In the log i can see all necessary data when i list full dataserviceSetting, but i cant reach that.

I tried this way: dataserviceSetting.response.body.versions[0];
But it generate error undefined.

When i try to see only response object in console log:
console.log(dataserviceSetting.response);
content returned value is: Object {}

Other object under response is undefined in the log

How can i get respons object content from this dataserviceSetting?
Can i get some data from response object without use apperio data mapping menu?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Get response object data outside from mapping area

Hi Kis,

Yes. Please add a service Success event handler, where the whole service response will be available in a variable 'data'.

kis vukk
Posts: 0
Joined: Tue Oct 07, 2014 12:49 pm

Get response object data outside from mapping area

Hi Kateryna

I can use Success event handler on dataserviceSetting and there i can work with data object content.
Placed return data; to end of Success event handler.

Try to reach data object from Screen Load event after call

dataserviceSetting.execute({
"onSuccess": function(data) {
console.log("ONSUCCESS1: "+data);
console.log("ONSUCCESS2: "+dataserviceSetting.response.body.versions[0]);
},
"onError": function(textStatus) {
console.log("ONERROR: "+textStatus);
}
});

But data is undefined.

Noticed Screen Load process run first and dataserviceSetting Success event run after when Screen Load finished, and do not return with data object.
In log:
startscreen load js - End! startScreen.js:355
datasetting success js - end! startScreen.js:273
success

So success event return after screen load js ending.

I know how to work with "data" object on dataserviceSetting event handler admn area, i can work with data object, can use all of that content.

Quetion is how to return data object content in screen Load process?
Or i shoud be use data object on event handler area, work with data there and send the result to where i want?

The aim: Start screen content depend on what's in this returned data object. dataserviceSetting is pre check a mysql database content (version) in screen load process before load any other content.

  • if data object content verison same in localstore version don't want to call any other REST services, load the content from localstorage,

  • if version different call REST services and update localstorage content and show it to user after screen loaded.

    I need to get data object as soon as possible before any content show to user. I did it in Screen Load process but maybe Before Load process the right place to do this. I try it.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Get response object data outside from mapping area

Hi Kis,

Here is a correct way to handle success event by JS:

pre

var onSuccess = function(data){
console.log("success");
console.log(data);
};

dogsList11.execute({success: onSuccess});

/pre

Regards.

kis vukk
Posts: 0
Joined: Tue Oct 07, 2014 12:49 pm

Get response object data outside from mapping area

Great, thank you!

Return to “Issues”