Skip to content

Commit

Permalink
fix(lib): change HttpClient to HttpBackend
Browse files Browse the repository at this point in the history
change is for not using native HttpCLient Interceptors
  • Loading branch information
rshchpkn committed Mar 29, 2018
1 parent b4369cf commit 67871ac
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/ngx-restangular-http.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {Observable} from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import { HttpBackend, HttpErrorResponse, HttpRequest, HttpResponse } from '@angular/common/http';

import 'rxjs/add/observable/throw'
import 'rxjs/add/operator/map'
import 'rxjs/add/operator/catch'
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/filter';

import {RestangularHelper} from './ngx-restangular-helper';
import { RestangularHelper } from './ngx-restangular-helper';

@Injectable()
export class RestangularHttp {

constructor(public http: HttpClient) {
constructor(public http: HttpBackend) {
}

createRequest(options) {
let request = RestangularHelper.createRequest(options);
const request = RestangularHelper.createRequest(options);

return this.request(request);
}

request(request) {
return this.http.request(request.method, request.url, {...request, observe: 'response' })
request(request: HttpRequest<any>) {
return this.http.handle(request)
.filter(event => event instanceof HttpResponse)
.map((response: any) => {
if (!response.ok) {
return Observable.throw(new HttpErrorResponse(response));
Expand Down

0 comments on commit 67871ac

Please sign in to comment.