How to use the @angular/http.Request function in @angular/http

To help you get started, we’ve selected a few @angular/http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tkssharma / Web-Development-with-Angular-2-and-Bootstrap / ng-2-training / ng-2-Dashboard / src / app / http.service.ts View on Github external
private request(url: string, method: RequestMethod, body?: any, isBlob = false): Observable {

    const options = new BaseRequestOptions();
    options.url = url;
    options.method = method;
    options.body = body;
    if(isBlob) {
      options.responseType = ResponseContentType.Blob;
    }
    const request = new Request(options);
    return this.http.request(request)
      .catch((error: any) => this.onErrorHandler(error));
  }
github tkssharma / Web-Development-with-Angular-2-and-Bootstrap / ng-2-training / ng-2-cart / src / app / http.service.ts View on Github external
private request(url : string, method : RequestMethod, body?: any, isBlob = false) : Observable < Response > {
    this.showLoader();
    const options = new BaseRequestOptions();
    options.url = url;
    options.method = method;
    options.body = body;
    if (isBlob) {
      options.responseType = ResponseContentType.Blob;
    }
    const request = new Request(options);
    return this
      .http
      .request(request)
      .catch((error : any) => this.onErrorHandler(error))
      . finally(() => {
        this.onEnd();
      });
  }
github r-park / soundcloud-ngrx / src / app / core / services / api / api-service.ts View on Github external
request(options: IRequestOptions): Observable {
    const req: Request = new Request(this.requestArgs(options));
    return this.http.request(req)
      .map((res: Response) => res.json());
  }
github Apress / pro-angular-2ed / Update for Angular 5 / Updated Source Code / Source Code / Chapter 09 / SportsStore / src / app / model / rest.datasource.ts View on Github external
private sendRequest(verb: RequestMethod,
            url: string, body?: Product | Order, auth: boolean = false)
                : Observable {

        let request = new Request({
            method: verb,
            url: this.baseUrl + url,
            body: body
        });
        if (auth && this.auth_token != null) {
            request.headers.set("Authorization", `Bearer<${this.auth_token}>`);
        }
        return this.http.request(request).map(response => response.json());
    }
}
github outcobra / outstanding-cobra / frontend / src / app / core / http / http-interceptor.ts View on Github external
request(request: RequestOptions): Observable {
        request.method = (request.method || RequestMethod.Get);
        request.url = (request.url || '');
        request.headers = (request.headers || {});
        request.data = (request.data || {});
        request.params = (request.params || {});
        request.apiName = (request.apiName || this._defaultApiName);

        this._interpolateUrl(request);

        this._addContentType(request);

        this._addAuthToken(request);

        return this.http.request(
            new Request({
                method: request.method,
                url: this._buildApiUrl(request),
                headers: request.headers,
                search: this._buildUrlSearchParams(request.params),
                body: JSON.stringify(request.data, dateReplacer)
            } as RequestArgs)
        ).catch(error => this._handleError(error))
            .map((res: Response) => this._unwrapAndCastHttpResponse(res));
    }
github microsoft / IIS.WebManager / src / app / connect / httpconnection.ts View on Github external
public options(conn: ApiConnection, path: string): Observable {

        if (path.indexOf("/") != 0) {
            path = '/' + path;
        }

        let opts: RequestOptionsArgs = {
            method: RequestMethod.Options,
            url: conn.url + path,
            headers: new Headers(),
            search: undefined,
            body: undefined
        };

        return this._http.request(new Request(new RequestOptions(opts)));
    }
github cloudfoundry / stratos / src / frontend / packages / store / src / helpers / paginated-request-helpers.ts View on Github external
public fetch(options: RequestOptions): Observable {
    return this.http.request(new Request(options)).pipe(
      map(this.getJsonData),
    );
  }
github byavv / mea2n / src / client / app / shared / services / extHttp.ts View on Github external
return Observable.create((observer: Observer) => {
            this.process.next(Action.QueryStart);
            this._http.request(new Request(requestOptions))
                .map((res) => res.json())
                .finally(() => {
                    this.process.next(Action.QueryStop);
                })
                .subscribe((res) => {
                    if (reqOptions.handle !== false) {
                        observer.next(this.serverHandler.handleSuccess(res));
                    } else {
                        observer.next(res);
                    }
                    observer.complete();
                },
                (err) => {                    
                    if (reqOptions.handle !== false) {
                        observer.error(this.serverHandler.handleError(err));
                    } else {
github Abdallah-khalil / ContactManagerApp / src / client / app / shared / api.service.ts View on Github external
request(url: string, method: RequestMethod, body?: Object): Observable {
    const headers = new Headers();
    headers.append('Content-type', 'application/json');
    headers.append('Authorization', `Bearer ${this.authService.getToken()}`);
    const requestOptions = new RequestOptions({
      url: `${this.baseUrl}/${url}`,
      headers: headers,
      method: method
    });

    if (body) {
      requestOptions.body = body;
    }

    const req = new Request(requestOptions);
    return this.http.request(req)
      .map((res: Response) => res.json())
      .catch((error: Response) => this.onRequestError(error));
  }