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?
1 person has
this question
+1
This topic is no longer open for comments or replies.
  • Hi Kis,

    Yes. Please add a service Success event handler, where the whole service response will be available in a variable 'data'.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • 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.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • Hi Kis,

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



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

    dogsList11.execute({success: onSuccess});



    Regards.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned