Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(common): accept object map for HttpClient headers & params #18490

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
7 participants
@alxhub
Copy link
Contributor

commented Aug 2, 2017

Today, constructing a new GET request with headers looks like:

const headers = new HttpHeaders({
'My-Header': 'header value',
});
http.get('/url', {headers}).subscribe(...);

This indirection is unnecessary. It'd be more ergonomic to write:

http.get('/url', {headers: {'My-Header': 'header value'}}).subscribe(...);

This commit allows that new syntax, both for HttpHeaders and HttpParams.
In the HttpParams case it also allows construction of HttpParams with a map.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] angular.io application / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[ ] No

Other information

@googlebot googlebot added the cla: yes label Aug 2, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Aug 2, 2017

@cexbrayat
Copy link
Contributor

left a comment

👍 Not mentioned, but this fixes #18012

@@ -69,6 +79,7 @@ export function main() {
it('that returns a stream of events', (done: DoneFn) => {
client.get('/test', {observe: 'events'}).toArray().toPromise().then(events => {
expect(events.length).toBe(2);
let x = HttpResponse;

This comment has been minimized.

Copy link
@cexbrayat

cexbrayat Aug 3, 2017

Contributor

@alxhub Probably not needed

This comment has been minimized.

Copy link
@alxhub

alxhub Aug 7, 2017

Author Contributor

Good catch!

@alxhub alxhub force-pushed the alxhub:http-client-raw-params branch from 615e4dc to b5abf72 Aug 7, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Aug 7, 2017

feat(common): accept object map for HttpClient headers & params
Today, constructing a new GET request with headers looks like:

const headers = new HttpHeaders({
  'My-Header': 'header value',
});
http.get('/url', {headers}).subscribe(...);

This indirection is unnecessary. It'd be more ergonomic to write:

http.get('/url', {headers: {'My-Header': 'header value'}}).subscribe(...);

This commit allows that new syntax, both for HttpHeaders and HttpParams.
In the HttpParams case it also allows construction of HttpParams with a map.

@alxhub alxhub force-pushed the alxhub:http-client-raw-params branch from b5abf72 to 2427a12 Aug 28, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Aug 28, 2017

@Vandivier

This comment has been minimized.

Copy link

commented Jan 8, 2018

Process question: Why was this marked closed instead of merged?

@IgorMinar

This comment has been minimized.

Copy link
Member

commented Jan 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.