Skip to content

Commit 634d431

Browse files
committed
Changed .sendHttpRequest() to .request()
1 parent a916399 commit 634d431

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,19 +338,19 @@ const routerConfig: Routes = [
338338
## Advanced Usage
339339
More advanced methods can be used if a higher degree of customization is required.
340340
341-
### .sendHttpRequest()
342-
More customized requests can be send with the `.sendHttpRequest()`-function. It accepts the RequestOptions-Class.
343-
More information can be found in the Angular2 API Reference [here](https://angular.io/docs/ts/latest/api/http/index/RequestOptions-class.html).
341+
### .request()
342+
More customized requests can be send with the `.request()`-function. It accepts the RequestOptionsArgs-Interface.
343+
More information can be found in the Angular2 API Reference [here](https://angular.io/docs/ts/latest/api/http/index/RequestOptionsArgs-interface.html).
344344
345-
`sendHttpRequest(options: RequestOptions): Observable<Response>`
345+
`request(options: RequestOptionsArgs): Observable<Response>`
346346
347347
#### Example:
348348
```javascript
349-
this.sendHttpRequest(new RequestOptions({
349+
this._tokenService.request({
350350
method: RequestMethod.Post,
351351
url: 'my-resource/1',
352352
data: mydata
353-
}));
353+
});
354354
```
355355
356356
### .userSignedIn()

src/angular2-token.service.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
Headers,
77
Request,
88
RequestMethod,
9-
RequestOptions
9+
RequestOptions,
10+
RequestOptionsArgs
1011
} from '@angular/http';
1112
import { ActivatedRoute, Router } from '@angular/router';
1213
import { Observable } from 'rxjs/Observable';
@@ -248,59 +249,59 @@ export class Angular2TokenService implements CanActivate {
248249

249250
// Standard HTTP requests
250251
get(path: string): Observable<Response> {
251-
return this.sendHttpRequest(new RequestOptions({
252+
return this.request({
252253
method: RequestMethod.Get,
253254
url: this._constructApiPath() + path
254-
}));
255+
});
255256
}
256257

257258
post(path: string, data: any): Observable<Response> {
258-
return this.sendHttpRequest(new RequestOptions({
259+
return this.request({
259260
method: RequestMethod.Post,
260261
url: this._constructApiPath() + path,
261262
body: data
262-
}));
263+
});
263264
}
264265

265266
put(path: string, data: any): Observable<Response> {
266-
return this.sendHttpRequest(new RequestOptions({
267+
return this.request({
267268
method: RequestMethod.Put,
268269
url: this._constructApiPath() + path,
269270
body: data
270-
}));
271+
});
271272
}
272273

273274
delete(path: string): Observable<Response> {
274-
return this.sendHttpRequest(new RequestOptions({
275+
return this.request({
275276
method: RequestMethod.Delete,
276277
url: this._constructApiPath() + path
277-
}));
278+
});
278279
}
279280

280281
patch(path: string, data: any): Observable<Response> {
281-
return this.sendHttpRequest(new RequestOptions({
282+
return this.request({
282283
method: RequestMethod.Patch,
283284
url: this._constructApiPath() + path,
284285
body: data
285-
}));
286+
});
286287
}
287288

288289
head(path: string): Observable<Response> {
289-
return this.sendHttpRequest(new RequestOptions({
290+
return this.request({
290291
method: RequestMethod.Head,
291292
url: this._constructApiPath() + path
292-
}));
293+
});
293294
}
294295

295296
options(path: string): Observable<Response> {
296-
return this.sendHttpRequest(new RequestOptions({
297+
return this.request({
297298
method: RequestMethod.Options,
298299
url: this._constructApiPath() + path
299-
}));
300+
});
300301
}
301302

302303
// Construct and send Http request
303-
sendHttpRequest(requestOptions: RequestOptions): Observable<Response> {
304+
request(options: RequestOptionsArgs): Observable<Response> {
304305

305306
let baseRequestOptions: RequestOptions;
306307
let baseHeaders: { [key:string]: string; } = this._options.globalOptions.headers;
@@ -321,7 +322,7 @@ export class Angular2TokenService implements CanActivate {
321322
});
322323

323324
// Merge standard and custom RequestOptions
324-
baseRequestOptions = baseRequestOptions.merge(requestOptions);
325+
baseRequestOptions = baseRequestOptions.merge(options);
325326

326327
let response = this._http.request(new Request(baseRequestOptions)).share();
327328

0 commit comments

Comments
 (0)