viezel / napp.alloy.adapter.restapi

RestAPI Sync Adapter for Titanium Alloy Framework
197 stars 102 forks source link

Unable to do a POST request #47

Closed fabiomlferreira closed 10 years ago

fabiomlferreira commented 10 years ago

I want to POST some data to authenticate the user right know I have this: var model = Alloy.createModel("login");

model.save({ 
    params: { 
        username: "username",
        password: "pass" 
    },
    //parse:false,
    success : function(e){
    },
    error : function(){
        Ti.API.error("hmm - this is not good!");
    },
});

But the website never receive the POST data. I don't now if is my problem or problem with the adapter.restapi

viezel commented 10 years ago

Hi @invaderhd First of all. you do not want to put the user credentials in url params, because they can be read by anyone. Then using model.save() you are doing a POST request. So use the request body.

Secondly, please read the Backbone docs: http://backbonejs.org/#Model-save as this adapter follows the Backbone structure.

model.save(attrs, obj)

in your case it will be:

model.save({ username: "username", password: "pass" },{
    success : function(e){
    },
    error : function(e){
    },
});