I want to use the parse.com platform. But I have some problems getting the results of a query with a "sort by". I have used the parse.js code from an example of the Appcelerator Blog. It seems that HTTPClient switches from GET to POST if a pass some parameters to xhr.send. Or did I do something wrong?
Here is the code:
Code in app.js:
client.getAllParms( { success : getSportwagen, className : 'hersteller', object: { order: 'name' } });
Code in parse.js:
Client.prototype.getAllParms = function(args) { this.request({ url:args.className, method:'GET', payload:args.object, success:args.success, error:args.error }); }; Client.prototype.request = function(args) { var xhr = Ti.Network.createHTTPClient(), that = this; alert(args); xhr.onload = function() { alert(this.responseData); var response = JSON.parse(this.responseText); Ti.API.debug('Parse Client: Request Successful'); (args.success) ? args.success(response) : Ti.API.debug('Parse Client: Request Successful'); }; xhr.onerror = function() { var response = JSON.parse(this.responseText); (args.error) ? args.error(response,this) : Ti.API.error('Parse Client: Request Failed: '+args.url); }; Ti.API.debug('parse url = ' + ENDPOINT+args.url); xhr.open(args.method,ENDPOINT+args.url); var authString = Base64.encode(that.applicationId+':'+that.masterKey); xhr.setRequestHeader('Authorization', 'Basic '+authString); xhr.setRequestHeader('Content-Type','application/json'); if (args.method === 'PUT' || args.method === 'POST' || (args.method === 'GET' && !!args.payload)) { xhr.send(JSON.stringify(args.payload)); } else { xhr.send(''); } };