-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,10 +54,9 @@ function clientSync(method, model, options) { | |
} | ||
|
||
function serverSync(method, model, options) { | ||
var api, data, urlParts, verb, req; | ||
var api, urlParts, verb, req; | ||
|
||
data = _.clone(options.data); | ||
options.url = this.getUrl(options.url, false, data); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
alexindigo
Member
|
||
options.url = this.getUrl(options.url, false); | ||
verb = methodMap[method]; | ||
urlParts = options.url.split('?'); | ||
req = this.app.req; | ||
|
@@ -70,14 +69,8 @@ function serverSync(method, model, options) { | |
body: {} | ||
}; | ||
|
||
/** | ||
* Put the data as form data if POST or PUT, | ||
* otherwise query string. | ||
*/ | ||
if (verb === 'POST' || verb === 'PUT') { | ||
api.body = data; | ||
} else { | ||
_.extend(api.query, data); | ||
api.body = _.omit(model.toJSON(), model.idAttribute); | ||
} | ||
|
||
req.dataAdapter.request(req, api, function(err, response, body) { | ||
|
7 comments
on commit 8c8d7ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has forced us to write our own fetch() method that puts params into the query string of a request when we're doing the server request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lo1tuma That's unfair. Not sure what we were supposed to do. Almost all the code in rendr is undocumented and a lot of it is untested. We have things to get done and one way to figure out how stuff works was to put console.log
s everywhere in the module until I got what I wanted.
We want to use rendr. However, lots of it has to be figured out by peering inside the library's code. I personally don't have time to create tests for the untested features I figure out and use. I want to get things done.
I'm not blaming you. I think we should bring that back and explain what it does via tests and documentation (although the examples serve as documentation and use interpolated params)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand that. But you have to consider that rendr hasn’t released a stable version yet. Until we release rendr 1.0 there can be a breaking change in every version.
However, the problem here was that I didn’t know about that hidden rendr feature and I was fixing another bug. I removed that feature unintentionally. Since it was not tested I could not realize that I broke it.
As already said, the first step to bring this feature back, would be to create an issue (feature request). Although I personally think such a feature is out of rendr’s scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lo1tuma I agree this is not the responsibility of rendr. It should be handled by the developer, using the url as a function if the attributes are dynamic.
Therefore I'd be more interested in a PR removing the feature entirely (including from the examples obv.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lo1tuma A good rule of thumb is to not remove code you don't understand or has interactions you don't understand. If you'd like to have a fully documented, tested code base, rendr is not that starting point. If you'd like to add tests to cover the existing usage of behavior, we could all reason about it moving forward.
Smaller commits that target specific features and changes are a lot easier for people who are using a library to reason about and communicate on. Nothing in the name "Fix client sync to support correct json payload" covers the removal of adding parameters to URLs.
This ended up being an important feature that got broken between a 0.5-rc1 release and the tagged 0.5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data was used to build URLs. This was pretty useful.