Page 1 of 1

object to array via Generic Security Context service

Posted: Mon Aug 04, 2014 11:21 am
by Rainer

I use a List_Service via REST API to read data from an external DB.
From there I get back and Object and not an Array.
We think because of this we always get undefinded when we map the data to an UI component.

Now I found in the forum some explanation about this and a possibel solution via using a Generic Security Context service.

We found this sample:

var yourObject = {
"converation1": {
name: "John",
tag: "good"
},
"converation2": {
name: "Mike",
tag: "better"
}
};
var newArray = [];
for (var i in yourObject) {
var currentObject = yourObject;
currentObject["iteration"] = i;
newArray.push(currentObject);
};
console.log(newArray);

How can we have in "yourObject" instead an object string like in the sample the real object comming via the list_service from the external database.


object to array via Generic Security Context service

Posted: Mon Aug 04, 2014 2:07 pm
by Evgene Karachevtsev

Hello Rainer,

Generic Security service Context is not very suitable for you. Generic service (http://devcenter.appery.io/documentat...) will approach to you more. Or you may use 2 services, one list service which receives all the data, and the second one is rest service. On success event of list service all data arrive in the variable data. You may form data in the required form (as an array) of this data and record it in the echo of the second service (http://devcenter.appery.io/documentat...). And then you should call a second service.