[TIMOB-15093] Use data parameter for GET request in httpclient too
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.1.2 |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Kevin Purnelle |
Assignee | Unknown |
Created | 2013-08-06T14:16:02.000+0000 |
Updated | 2018-02-28T20:04:27.000+0000 |
Description
Hello,
At this time, it's possible to pass a data argument to httpClient.send method for POST request. (an object will be serialized)
I don't know if people would need the following but I found it useful.
I didn't want to concatenate params to url by hand anymore, for GET requests.
A more elegant solution was to create a simple function that would do the same for GET request as you do for POSTs.
For example at this time I do the following:
var reqUrl = http://api.whatever.com/users/search.json
var params = { age: 25, sex: male }
...
xhr.open('GET', reqUrl + paramsToUrl(params))
xhr.send()
This results in the following request:
http://api.whatever.com/users/search.json?age=25&sex=male
It would be nice to have this supported natively by titanium.
So doing this:
xhr.open('GET', reqUrl)
xhr.send(params)
would have the same result as my function.
I think this adds some nice abstraction and a clearer code.
What do you think?
Let me see if I understand you correctly... You want to change the [xmlHTTPRequest Object ](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) so the SEND method will QS your params automatically for you?
I often had code like this:
Instead I wish we could do that:
It's similar to POST request syntax, and nicer. (o maybe there is something I don't know that could improve what I do)