当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript HttpHeaders.append方法代码示例

本文整理汇总了TypeScript中@angular/common/http.HttpHeaders.append方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpHeaders.append方法的具体用法?TypeScript HttpHeaders.append怎么用?TypeScript HttpHeaders.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/common/http.HttpHeaders的用法示例。


在下文中一共展示了HttpHeaders.append方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: send

 send(post: any) {
   let the_headers = new HttpHeaders();
   the_headers.append('Content-Type', 'multipart/form-data;boundary='+Math.random());
   the_headers.append('Accept', 'application/json');
   return this.http.post(environment.api_url + '/celty', post, {headers: the_headers})
     .map(res => res);
 }
开发者ID:Fermoto5HD,项目名称:SitioPersonal,代码行数:7,代码来源:celty.service.ts

示例2: loadAlbumPhoto

  /**
   * Load photos for specified album
   * @param albumid ID of album
   * @param accesscode Access code
   * @param top Maximum amount of the photo to fetch
   * @param skip The amount to skip in the result
   */
  public loadAlbumPhoto(albumid: string | number, accesscode?: string, top?: number, skip?: number): Observable<any> {
    let params: HttpParams = new HttpParams();
    params = params.append('albumid', albumid.toString());
    if (accesscode) {
      params = params.append('accesscode', accesscode);
    }
    if (top) {
      params = params.append('top', top.toString());
    }
    if (skip) {
      params = params.append('skip', skip.toString());
    }

    let headers = new HttpHeaders();
    headers = headers.append('Content-Type', 'application/json')
      .append('Accept', 'application/json');
    if (this._authService.authSubject.getValue().isAuthorized) {
      headers = headers.append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());
      return this._http.get(environment.PhotoAPIUrl, {
        headers: headers,
        params: params });
    }

    return this._http.get(environment.PhotoAPIUrl, {
        headers: headers,
        params: params,
      });
  }
开发者ID:alvachien,项目名称:acgallery,代码行数:35,代码来源:photo.service.ts

示例3: getHeaders

 /**
  * This is a Global place to add all the request headers for every REST calls
  */
 getHeaders():HttpHeaders {
     let headers = new HttpHeaders();
     let token = this.userInfoService.getStoredToken();
     headers = headers.append('Content-Type', 'application/json');
     if (token !== null) {
         headers = headers.append("Authorization", token);
     }
     return headers;
 }
开发者ID:sayjavajava,项目名称:Angular-SpringBoot-REST-JWT,代码行数:12,代码来源:api-request.service.ts

示例4: getTagCount

  /**
   * Get Tag count
   */
  public getTagCount(): Observable<any> {
    const apistring = environment.PhotoTagCountAPIUrl;
    let headers = new HttpHeaders();
    headers = headers.append('Content-Type', 'application/json')
      .append('Accept', 'application/json');
    if (this._authService.authSubject.getValue().isAuthorized) {
      headers = headers.append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());
    }

    return this._http.get(apistring, { headers: headers});
  }
开发者ID:alvachien,项目名称:acgallery,代码行数:14,代码来源:photo.service.ts

示例5: header

 /**
  * 添加Http头
  * @param name 名称
  * @param value 值
  */
 header(name: string, value): HttpRequest<T> {
     let stringValue = "";
     if (value !== undefined && value !== null)
         stringValue = String(value);
     this.headers = this.headers.append(name, stringValue);
     return this;
 }
开发者ID:zousq19910623,项目名称:Util,代码行数:12,代码来源:http-helper.ts

示例6: getShellToken

  getShellToken(namespace: string, podName: string): Observable<any> {
    let headers = new HttpHeaders();
    const username = 'publicV1'
    const password = 'a1b2c3d4E'
    headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
    headers.append('Content-Type', 'application/x-www-form-urlencoded');
    const options: any = {'headers': headers};

    let urlSearchParams = new HttpParams();
    urlSearchParams.append('namespace', namespace);
    urlSearchParams.append('podName', podName);
    return this.http
      .post(`/api/v1/public/shell/token`, urlSearchParams, options)

      .catch(error => Observable.throw(error));
  }
开发者ID:jacky68147527,项目名称:wayne,代码行数:16,代码来源:public.service.ts

示例7: saveDetailInfo

  /**
   * Save detail info
   */
  public saveDetailInfo(usrInfo: UserDetail): Observable<any> {
    if (environment.LoggingLevel >= LogLevel.Debug) {
      console.log('ACGallery [Debug]: Entering method saveDetailInfo of UserDetailService...');
    }

    let headers = new HttpHeaders();
    headers = headers.append('Content-Type', 'application/json')
      .append('Accept', 'application/json')
      .append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());

    const jdata: any = JSON && JSON.stringify(usrInfo);

    if (this._infoLoaded) {
      // Change
      const apichgurl = environment.UserDetailAPIUrl + '/' + this._authService.authSubject.getValue().getUserID();
      return this._http.put(apichgurl, jdata, { headers: headers }).pipe(map((value: any) => {
        this._infoLoaded = true;
        this._usrdetail = usrInfo;
      }));
    } else {
      // Create
      return this._http.post(environment.UserDetailAPIUrl, jdata, { headers: headers }).pipe(map((value: any) => {
        this._infoLoaded = true;
        this._usrdetail = usrInfo;
      }));
    }
  }
开发者ID:alvachien,项目名称:acgallery,代码行数:30,代码来源:user-detail.service.ts

示例8: readDetailInfo

  /**
   * Read detail ifno.
   */
  public readDetailInfo(): Observable<any> {
    if (environment.LoggingLevel >= LogLevel.Debug) {
      console.log('ACGallery [Debug]: Entering method readDetailInfo of UserDetailService...');
    }

    let headers = new HttpHeaders();
    headers = headers.append('Content-Type', 'application/json')
      .append('Accept', 'application/json')
      .append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());

    const apiurl = environment.UserDetailAPIUrl + '/' + this._authService.authSubject.getValue().getUserID();
    return this._http.get(apiurl, { headers: headers })
      .pipe(map((response: any) => {
        this._infoLoaded = true;

        this._usrdetail = new UserDetail();
        this._usrdetail.onSetData(response);
        return this._usrdetail;
      }),
      catchError((error: HttpErrorResponse) => {
        if (error) {
          // Log the error?
        }

        this._infoLoaded = false;
        return of(undefined);
      }));
  }
开发者ID:alvachien,项目名称:acgallery,代码行数:31,代码来源:user-detail.service.ts

示例9: getAuthWithParams

  getAuthWithParams(url, params?): Observable<any> {
    console.log(params);
    let headers = new HttpHeaders();
    headers = headers.append('Authorization', 'Basic ' + btoa('token:' + this.tokenService.getToken()));

    return this.httpClient.get(url, {headers: headers, params: params});

  }
开发者ID:chipster,项目名称:chipster-web,代码行数:8,代码来源:auth-http-client.service.ts

示例10: HttpHeaders

 postJson<T>(url: string, json: any) {
   const header = new HttpHeaders();
   header.append('Content-Type', 'application/json;charset=UTF-8');
   return this.http.post<T>(url, json, {
     headers: header,
     withCredentials: true
   });
 }
开发者ID:CAaRrLl,项目名称:Blog,代码行数:8,代码来源:http.service.ts


注:本文中的@angular/common/http.HttpHeaders.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。