1

Defined as a model and its associations, I wish the http calls to follow best practices of restful. For example, if I make the call

user.posts();

I wish to run a call http defined as

users/1/posts

If a call is then put on post with id 32 then the url of reference must be

users/1/posts/32

So I want to avoid using the filter property as is the default for a get

/posts.php?filter=[{"property":"user_id","value":1}] 

This is because the api rest are already defined and I can not change them. I would like to build a minimally invasive solution and reading on various forums the best way is to do an ovveride the method buildURL the proxy rest but was not able to retrieve all the data needed to build the final URL. Can anyone give me an example?

thanks

Giuseppe Toto
  • 205
  • 3
  • 9
  • The standard Sencha REST proxy (http://docs.sencha.com/touch/2.4/apidocs/#!/api/Ext.data.proxy.Rest) handles this for you, but it sounds more like you are looking specifically for custom *association* proxy functionality. Also - when you say "was not able to retrieve all the data needed to build the final URL" - can you please elaborate? What are you not able to retrieve that is preventing you from building the override? – OhmzTech Nov 20 '14 at 06:34
  • I use proxy rest but as I said the default does not use the rest standard when it is necessary to refer to nested resources. For example if I want to see all tasks associated at one user, according to the standard rest should do a call get: "http://domain.com/user/1/tasks" Instead REST PROXY makes a call on "http://domain.com/tasks.php?filter=[{"property":"user_id","value":1}] – Giuseppe Toto Nov 20 '14 at 14:06

1 Answers1

0

Try the following:

window.serverUrl = "192.168.1.XX"
var service = "login.php"

var dataTosend: {
    username:"xx",
     password: "yy"
}
var methode:"POST" / "GET"
this.service(service,methode,dataTosend,onSucessFunction,onFailureFunction);

onSucessFunction: function(res) {
   alert("onSucessFunction"):
},

onFailureFunction: function(res) {
   alert("onFailureFunction"):
},


service: function(svc, callingMethod, data, successFunc, failureFunc) {
        Ext.Ajax.request({
            scope: this,
            useDefaultXhrHeader: false,
            method: callingMethod,
            url: window.serverUrl + svc,
            params: data,
            reader: {
                type: 'json'
            },
            failure: failureFunc,
            success: successFunc
        });

I hope this will solve your problem...

parakmiakos
  • 2,994
  • 9
  • 29
  • 43
Manjappa
  • 21
  • 3