Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Generic Service (JSON)

How do I program a Generic Rest Service to return a response containing and array of json objects?

Do I do something like this (complete guess):

preAppery.areas = Appery.createClass(null, {

Code: Select all

 init : function(requestOptions) { 
     this.__requestOptions = $.extend({}, requestOptions); 
 }, 

 process : function(settings) { 
     settings.beforeSend(settings); 
     if (this.__requestOptions.echo) { 
         settings.success(this.__requestOptions.echo); 
     } else { 
         // return the response 
         var jsonString = "[{ 
             "title" : "xxxxx", 
             "link" : "yyyyyy" 
         }, { 
             "title": "aaaaa", 
             "link": "bbbbb" 
         }]" 
         return jsonString; 
         settings.success({}); 
     } 
     settings.complete('success'); 
 } 

});/pre

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Generic Service (JSON)

Ok, i think I found it in the old docs by googling it,

The response goes in the "settings.success({}); line yes?

so would my reponse be something like:

presettings.success(
[{
"title" : "xxxxx",
"link" : "yyyyy"
}, {
"title" : "aaaaa",
"link" : "bbbbb"
}]
); /pre

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Generic Service (JSON)

Hello Terry,

Yes, you are right, please use a response of the generic service like that.

Return to “Issues”