How to use the @angular/common/http.HttpRequest function in @angular/common

To help you get started, we’ve selected a few @angular/common 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 runbox / runbox7 / src / app / compose / compose.component.ts View on Github external
let fileName = file['webkitRelativePath'] ?
                file['webkitRelativePath'] :
                file.name;

            // Replace folder separator with underline
            fileName = fileName.replace(/\//g, '_');
            fileName = fileName.replace(/\\/g, '_'); // Don't know about windows, but better be safe

            // Add the file to the request.
            formdata.append('attachment', file, fileName);
        }
        formdata.append('mid', '' + this.model.mid);
        formdata.append('attach', 'Attach');
        formdata.append('ajaxAttach', 'Attach');

        this.http.request(new HttpRequest(
            'POST', '/ajax/upload_attachment', formdata,
            { reportProgress: true , headers: new HttpHeaders({ 'ngsw-bypass': '1' }) }
        )).subscribe((event) => {
            if (event.type === HttpEventType.UploadProgress) {
                const progress = event.loaded * 100 / event.total;
                this.uploadprogress = progress === 100 ? null : progress;
            } else if (event.type === HttpEventType.Response) {
                if (!this.model.attachments) {
                    this.model.attachments = [];
                }
                (event.body as any).result.attachments
                    .forEach((att: any) => {
                        att.file = att.filename;
                        this.model.attachments.push(att);
                    });
github adorsys / XS2A-Sandbox / oba-ui / src / app / api / services / psupiscancellation.service.ts View on Github external
pisDoneUsingGETResponse(params: PSUPISCancellationService.PisDoneUsingGETParams): __Observable<__StrictHttpResponse> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    if (params.forgetConsent != null) __params = __params.set('forgetConsent', params.forgetConsent.toString());

    if (params.backToTpp != null) __params = __params.set('backToTpp', params.backToTpp.toString());

    if (params.oauth2 != null) __params = __params.set('oauth2', params.oauth2.toString());
    if (params.Cookie != null) __headers = __headers.set('Cookie', params.Cookie.toString());
    let req = new HttpRequest(
      'GET',
      this.rootUrl + `/pis-cancellation/${params.encryptedPaymentId}/authorisation/${params.authorisationId}/done`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse;
      })
    );
  }
github cloudfoundry / stratos / src / frontend / packages / cloud-foundry / src / actions / stack.action.ts View on Github external
constructor(public guid: string, public endpointGuid: string) {
    super();
    this.options = new HttpRequest(
      'GET',
      `stacks/${guid}`
    );
  }
  actions = [
github unfetter-discover / unfetter-ui / src / app / core / services / genericapi.service.ts View on Github external
public uploadAttachments(files: File[], progressCallback?: (number) => void): Observable {
        const formData: FormData = new FormData();
        files.forEach((file) => formData.append('attachments', file));
        const req = new HttpRequest('POST', `${Constance.UPLOAD_URL}/files`, formData, {
            reportProgress: true
        }); 
        return this.uploadFile(req, progressCallback);
    }
github adorsys / XS2A-Sandbox / oba-ui / src / app / api / services / psupis.service.ts View on Github external
pisDoneUsingGET1Response(params: PSUPISService.PisDoneUsingGET1Params): __Observable<__StrictHttpResponse> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    if (params.forgetConsent != null) __params = __params.set('forgetConsent', params.forgetConsent.toString());

    if (params.backToTpp != null) __params = __params.set('backToTpp', params.backToTpp.toString());

    if (params.oauth2 != null) __params = __params.set('oauth2', params.oauth2.toString());
    if (params.Cookie != null) __headers = __headers.set('Cookie', params.Cookie.toString());
    let req = new HttpRequest(
      'GET',
      this.rootUrl + `/pis/${params.encryptedPaymentId}/authorisation/${params.authorisationId}/done`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse;
      })
    );
  }
github feater-dev / feater / spa / src / app / api / auth-http-client.service.ts View on Github external
private _request(method: string, url: string, body?: any, httpHeaders?: HttpHeaders): Observable> {
        if (!httpHeaders) {
            httpHeaders = new HttpHeaders();
        }

        const httpRequest = new HttpRequest(method, url, body, {
            headers: httpHeaders.set('x-feater-api-token', this._buildAuthHeader()),
        });

        return Observable.create((observer) => {
            this.process.next(Action.QueryStart);
            this._httpClient.request(httpRequest).pipe(
                finalize(() => {
                    this.process.next(Action.QueryStop);
                }))
                .subscribe(
                    (res) => {
                        observer.next(res);
                        observer.complete();
                    },
                    (err) => {
                        switch (err.status) {
github cloudfoundry / stratos / src / frontend / packages / cloud-foundry / src / actions / organization.actions.ts View on Github external
constructor(public guid: string, public endpointGuid: string) {
    super();
    this.options = new HttpRequest(
      'DELETE',
      `organizations/${guid}`,
      {
        params: new HttpHeaders({
          recursive: 'true',
          async: 'false'
        })
      }
    );
  }
  actions = [DELETE_ORGANIZATION, DELETE_ORGANIZATION_SUCCESS, DELETE_ORGANIZATION_FAILED];
github adorsys / XS2A-Sandbox / oba-ui / src / app / api / services / psuais.service.ts View on Github external
revokeConsentUsingDELETEResponse(params: PSUAISService.RevokeConsentUsingDELETEParams): __Observable<__StrictHttpResponse> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;


    if (params.Cookie != null) __headers = __headers.set('Cookie', params.Cookie.toString());
    let req = new HttpRequest(
      'DELETE',
      this.rootUrl + `/ais/${params.encryptedConsentId}/${params.authorisationId}`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse;
      })
    );
  }
github cloudfoundry / stratos / src / frontend / packages / cloud-foundry / src / actions / user-provided-service.actions.ts View on Github external
constructor(
    public guid: string,
    public endpointGuid: string,
    public includeRelations: string[] = [],
    public populateMissing = true
  ) {
    super();
    this.options = new HttpRequest(
      'GET',
      `user_provided_service_instances/${guid}`
    );
  }
  actions = getActions('User Provided Service', 'Get User Provided Service');
github adorsys / XS2A-Sandbox / oba-ui / src / app / api / services / psuais.service.ts View on Github external
startConsentAuthUsingPOSTResponse(params: PSUAISService.StartConsentAuthUsingPOSTParams): __Observable<__StrictHttpResponse> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;


    __body = params.aisConsent;
    if (params.Cookie != null) __headers = __headers.set('Cookie', params.Cookie.toString());
    let req = new HttpRequest(
      'POST',
      this.rootUrl + `/ais/${params.encryptedConsentId}/authorisation/${params.authorisationId}/start`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse;
      })
    );
  }