Skip to content

Commit

Permalink
fix(http): use params without RequestOptions (#14101)
Browse files Browse the repository at this point in the history
`params` has been introduced in 4.0.0-beta.0

Before:

    http.get(url, new RequestOptions({params: searchParams}))

After:

    http.get(url, {params: searchParams})

Fixes #14100

PR Close #14101
  • Loading branch information
cexbrayat authored and mhevery committed Feb 2, 2017
1 parent b57b14f commit fa18c83
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions modules/@angular/http/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function mergeOptions(
method: providedOpts.method || method,
url: providedOpts.url || url,
search: providedOpts.search,
params: providedOpts.params,
headers: providedOpts.headers,
body: providedOpts.body,
withCredentials: providedOpts.withCredentials,
Expand Down
15 changes: 13 additions & 2 deletions modules/@angular/http/test/http_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ export function main() {
.subscribe((res: Response) => {});
}));


it('should append string search params to url',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
backend.connections.subscribe((c: MockConnection) => {
Expand All @@ -365,7 +364,6 @@ export function main() {
.subscribe((res: Response) => {});
}));


it('should produce valid url when url already contains a query',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
backend.connections.subscribe((c: MockConnection) => {
Expand All @@ -378,6 +376,19 @@ export function main() {
}));
});

describe('params', () => {
it('should append params to url',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
backend.connections.subscribe((c: MockConnection) => {
expect(c.request.url).toEqual('https://www.google.com?q=puppies');
backend.resolveAllConnections();
async.done();
});
http.get('https://www.google.com', {params: {q: 'puppies'}})
.subscribe((res: Response) => {});
}));
});

describe('string method names', () => {
it('should allow case insensitive strings for method names', () => {
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
Expand Down

0 comments on commit fa18c83

Please sign in to comment.