viezel / napp.alloy.adapter.restapi

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

How can I pass parameters? #53

Open developer82 opened 9 years ago

developer82 commented 9 years ago

I would like to get a specific user details from my API server. How can I pass parameters with the fetch method with the user id? and possibly username & password?

Thanks

awamser commented 9 years ago

Passing the ID is done a little different than passing parameters. Id's are usually appended on to the end of the URL while parameters are encoded then passed.

https://url.com/1/classes/user/<ID>

Passing parameters is done using urlparams.

Alloy.Collections.State.fetch({
    urlparams : {
        where : '{"postal_code":"TX"}'
    },
    success : function() {
    },
    error : function() {
        Ti.API.error("hmm - this is not good!");
    }
});