How to use the @angular/common/http.HttpParams 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 Tangerine-Community / Tangerine / editor / src / app / groups / group-details / group-details.component.ts View on Github external
async deleteForm(groupName, formId) {
    console.log(groupName)
    console.log(formId)
    let confirmation = confirm('Are you sure you would like to remove this form?')
    if (!confirmation) return
    let formsJson = await this.http.get>(`/editor/${groupName}/content/forms.json`).toPromise()
    let newFormsJson = formsJson.filter(formInfo => formInfo.id !== formId)
    console.log(newFormsJson)

    await this.http.post('/editor/file/save', {
      groupId: groupName,
      filePath: './forms.json',
      fileContents: JSON.stringify(newFormsJson)
    }).toPromise()

    await this.http.delete('/editor/file/save', {params: new HttpParams()
      .set('groupId', groupName)
      .set('filePath', `./${formId}`)
    }).toPromise()

    this.forms = await this.groupsService.getFormsList(this.groupName);

    
  }
}
github damienbod / AspNet5IdentityServerAngularImplicitFlow / src / AngularClientIdTokenOnly / angularApp / app / auth / services / oidc.security.service.ts View on Github external
private createEndSessionUrl(
        end_session_endpoint: string,
        id_token_hint: string
    ) {
        const urlParts = end_session_endpoint.split('?');

        const authorizationEndsessionUrl = urlParts[0];

        let params = new HttpParams({
            fromString: urlParts[1],
            encoder: new UriEncoder()
        });
        params = params.set('id_token_hint', id_token_hint);
        params = params.append(
            'post_logout_redirect_uri',
            this.authConfiguration.post_logout_redirect_uri
        );

        return `${authorizationEndsessionUrl}?${params}`;
    }
github opfab / operatorfabric-core / ui / main / src / app / services / thirds.service.ts View on Github external
fetchActionMap(publisher: string, process: string, state: string, apiVersion?: string) {
        let params: HttpParams;
        if (apiVersion) params = new HttpParams().set("apiVersion", apiVersion);
        return this.httpClient.get(`${this.thirdsUrl}/${publisher}/${process}/${state}/actions`, {
            params,
            responseType: 'text'
        }).pipe(map((json: string) => {
            const obj = JSON.parse(json);
            return new Map(Object.entries(obj));
        }));
    }
}
github chef / automate / components / automate-ui / src / app / services / event-feed / event-feed.service.ts View on Github external
getSuggestions(type: string, text: string): Observable {
    if (text && text.length > 0) {
      const params = new HttpParams().set('type', type).set('text', text);
      const url = `${CONFIG_MGMT_URL}/suggestions`;

      return this.httpClient.get(url, {params}).pipe(map((suggestions: Chicklet[]) =>
        suggestions.map(item => item.text)));
    } else {
      return observableOf([]);
    }
  }
github alvachien / acgallery / src / app / services / album.service.ts View on Github external
public loadAlbumContainsPhoto(photoid: string): Observable {
    let headers = new HttpHeaders();
    headers = headers.append('Content-Type', 'application/json')
      .append('Accept', 'application/json')
      .append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());

    let params: HttpParams = new HttpParams();
    params = params.append('photoid', photoid);

    return this._http.get(environment.AlbumAPIUrl, {
      headers: headers,
      params: params,
    });
  }
github Cito / Pinboard-Pin / src / app / pinboard.service.ts View on Github external
httpGet(method: string, params?: any): Observable {
    params = params || {};
    if (!params.auth_token) {
      return this.storage.get('token').pipe(switchMap(token => {
        if (!token) {
          observableThrow(new Error('No API token!'));
        }
        params.auth_token = token;
        return this.httpGet(method, params);
      }));
    }
    params.format = 'json';
    const httpParams = Object.entries(params).reduce(
      (params: HttpParams, [key, value]: [string, string]) =>
        params.set(key, value), new HttpParams({encoder: paramsEncoder}));
    return this.http.get(
      apiUrl + method, {params: httpParams});
  }
github imolorhe / altair / src / app / services / gql / gql.service.ts View on Github external
getParamsFromData(data) {
    return Object.keys(data)
      .reduce(
        (params, key) => params.set(key, typeof data[key] === 'object' ? JSON.stringify(data[key]) : data[key]),
        new HttpParams()
      );
  }
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontapp / src / app / cms / services / occ-cms.service.ts View on Github external
if (currentPage !== undefined) {
      strParams === ''
        ? (strParams = strParams + 'currentPage=' + currentPage)
        : (strParams = strParams + '&currentPage=' + currentPage);
    }
    if (pageSize !== undefined) {
      strParams = strParams + '&pageSize=' + pageSize;
    }
    if (sort !== undefined) {
      strParams = strParams + '&sort=' + sort;
    }

    return this.http
      .post(this.getBaseEndPoint() + `/components`, idList, {
        headers: this.headers,
        params: new HttpParams({
          fromString: strParams
        })
      })
      .pipe(catchError((error: any) => observableThrowError(error.json())));
  }
github infra-geo-ouverte / igo2-lib / src / lib / search / search-sources / icherche-search-source.ts View on Github external
private getSearchParams(term: string): HttpParams {
    const limit = this.options.limit === undefined ? 5 : this.options.limit;
    const type =
      this.options.type ||
      'adresse,code_postal,route,municipalite,mrc,region_administrative';

    return new HttpParams({
      fromObject: {
        q: term,
        type: type,
        limit: String(limit),
        geometries: 'geom'
      }
    });
  }