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
base: master
from

Conversation

Projects
None yet
7 participants
@alxhub
Contributor

alxhub 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.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 2, 2017

@cexbrayat

👍 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.

@cexbrayat

cexbrayat Aug 3, 2017

Contributor

@alxhub Probably not needed

@cexbrayat

cexbrayat Aug 3, 2017

Contributor

@alxhub Probably not needed

This comment has been minimized.

@alxhub

alxhub Aug 7, 2017

Contributor

Good catch!

@alxhub

alxhub Aug 7, 2017

Contributor

Good catch!

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins 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.
@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 28, 2017

@Vandivier

This comment has been minimized.

Show comment
Hide comment
@Vandivier

Vandivier Jan 8, 2018

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

Vandivier commented Jan 8, 2018

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

@IgorMinar

This comment has been minimized.

Show comment
Hide comment
@IgorMinar

IgorMinar Jan 8, 2018

Member
Member

IgorMinar commented Jan 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment