-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(http): add multiple parameters serializers #7423
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
}); | ||
} | ||
|
||
function jsonParametersSerializer(params, callback) { |
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.
(as far as I'm aware,) no backend expects a JSON query string, that would be crazy
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 don't think it makes sense to ship more than one of these in core, we should probably just keep doing what we're already doing in core, and give people the option to extend it
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.
ok, that would be less code (and I always like less code)
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 don't think it makes sense to ship more than one of these in core, we should probably just keep doing what we're already doing in core, and give people the option to extend it
Mmm... not even the one that is asked at #7363 ?
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.
If you want jQuery behaviour, you could easily just say
$httpProvider.querySerializer('jquery', jQuery.param);
$httpProvider.defaultQuerySerializer = 'jquery';
to use jQuery's style automatically --- or if you didn't want to include jQuery, you could probably come up with a variation on it
Add the ability to add parameters serializers Add common parameters serializers Closes angular#7363
Instead of making the param serialization configurable, can't you just create an interceptor that will modify the config object by serializing the params, removing them from the config and updating the url? |
I definitely don't like having many different strategies in the core. We have one strategy that works quite well for most of the people. If that's not the case then we should consider adopting a better serialization strategy. For corner cases, you should be able to use interceptors. |
@IgorMinar are you saying that the proposed strategy should be to add an interceptor that changes the param from params: {
foo: [1, 2],
bar: { baz: 'abc' }
} to params: {
"foo[]": [1, 2],
"bar.baz" : 'abc'
} ? |
No. Remove params altogether and set the url to contain the params in
|
With the clarification from #7423 (comment) this is not going to be part of the core. Closing it |
Add the ability to add parameters serializers
Add common parameters serializers
Still needs quite some documentation changes, but putting it out to get feedback
Closes #7363