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


TypeScript HttpHeaders.set方法代码示例

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


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

示例1: constructor

    constructor(private http: HttpClient, configuration: Configuration) {

        this.actionUrl = configuration.Server + 'api/things/';

        this.headers = new HttpHeaders();
        this.headers = this.headers.set('Content-Type', 'application/json');
        this.headers = this.headers.set('Accept', 'application/json');
    }
开发者ID:damienbod,项目名称:Angular2WebpackVisualStudio,代码行数:8,代码来源:thing-data.service.ts

示例2: intercept

 intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
   var token = localStorage.getItem('token'); //1
   var newHeader: HttpHeaders = req.headers; //2
   newHeader = newHeader.set('Content-Type', 'application/json'); //3
   if(token) newHeader = newHeader.set('x-access-token', token); //4
   const newReq = req.clone({headers: newHeader}); //5
   return next.handle(newReq); //6
 }
开发者ID:wjs991,项目名称:dev_center,代码行数:8,代码来源:request-interceptor.service.ts

示例3: constructor

    constructor() {
        this.headers = new HttpHeaders();
        this.headers = this.headers.set('Content-Type', 'application/json');
        this.headers = this.headers.set('Accept', 'application/json');

        this.authHeaders = new HttpHeaders();
        this.authHeaders = this.headers;
        this.authHeaders = this.authHeaders.append('Authorization', `Bearer ${this.getToken()}`);
    }
开发者ID:1ceeeeee,项目名称:VentCalc,代码行数:9,代码来源:base.service.ts

示例4: getHeaders

    getHeaders(token, contentType):any {
        let headers:HttpHeaders = new HttpHeaders();
        if(token){
            headers = headers.set("Authorization", token.token_type + " " + token.access_token);
        }
 	if(contentType){
            headers = headers.set("Content-Type", contentType);
        }
        return headers;
    }
开发者ID:vmware,项目名称:lightwave,代码行数:10,代码来源:config.service.ts

示例5: constructor

  constructor(
    private services: Services
    //private store: Store<any>,
    //private oidcSecurityService: OidcSecurityService
  ) {
    this.headers = new HttpHeaders();
    this.headers = this.headers.set('Content-Type', 'application/json');
    this.headers = this.headers.set('Accept', 'application/json');

    this.init();
  }
开发者ID:pablonautic,项目名称:magiczny-miecz,代码行数:11,代码来源:GameHubClient.ts

示例6: transformRequest

 transformRequest() {
   let headers = new HttpHeaders();
   const headersObj = this.authenticationDataService.getRequestOptionsHeaders();
   for (const h of Object.entries(headersObj)) {
     headers = headers.set(h[0], h[1]);
   }
   return { headers: headers };
 }
开发者ID:strandls,项目名称:biodiv-mobile,代码行数:8,代码来源:http-auth.interceptor.ts

示例7: saveSkilltrees

  public saveSkilltrees(skilltrees: Skilltree[]) {
    let savedSkilltrees = [];

    skilltrees.forEach(skilltree => {
      let data: any = {ID: skilltree.id, Order: skilltree.order};
      if (skilltree.name) {
        data.Name = skilltree.name;
      }
      if (skilltree.requirements && skilltree.requirements.length > 0) {
        data.Requirements = skilltree.requirements;
      }
      if (skilltree.icon) {
        let icon: any = {};
        let save = false;
        if (skilltree.icon.material && skilltree.icon.material !== "") {
          icon.Material = skilltree.icon.material;
          save = true;
        }
        if (skilltree.icon.glowing) {
          icon.Glowing = skilltree.icon.glowing;
          save = true;
        }
        if (save) {
          data.Icon = icon;
        }
      }
      if (skilltree.inheritance && skilltree.inheritance.skilltree) {
        let inheritance: any = {};
        if (skilltree.inheritance.skilltree) {
          inheritance.Skilltree = skilltree.inheritance.skilltree;
        }
        data.Inheritance = inheritance;
      }
      if (skilltree.requiredLevel) {
        data.RequiredLevel = skilltree.requiredLevel;
      }
      if (skilltree.maxLevel) {
        data.MaxLevel = skilltree.maxLevel;
      }
      if (skilltree.description) {
        data.Description = skilltree.description.slice();
      }
      if (skilltree.weight && skilltree.weight != 1) {
        data.Weight = skilltree.weight;
      }
      data.MobTypes = this.saveMobTypes(skilltree.mobtypes.slice(0));

      data.Skills = {};
      this.saveSkills(data.Skills, skilltree.skills);
      this.saveNotifications(data, skilltree.messages);

      savedSkilltrees.push(data);
    });

    let headers = new HttpHeaders();
    headers = headers.set('Content-Type', 'application/json; charset=utf-8');
    return this.http.post("/api/skilltrees/save", savedSkilltrees, {headers});
  }
开发者ID:xXKeyleXx,项目名称:MyPet-SkilltreeCreator,代码行数:58,代码来源:skilltree-saver.service.ts

示例8: function

let authHeaders = function(headers?: HttpHeaders) : HttpHeaders {
    headers = headers ? headers : new HttpHeaders();

    return headers.set(
        "Authorization", localStorage.getItem("token")
    ).set(
        "Accept", "application/json"
    );
}
开发者ID:urandom,项目名称:readeef,代码行数:9,代码来源:api.ts

示例9: createAntiForgeryTokenHeader

 private createAntiForgeryTokenHeader(headers: HttpHeaders) {
     const tokenElement = document.all['__RequestVerificationToken'];
     if (!tokenElement) {
         console.log('Error: AntiForgeryToken not found.');
         return;
     }
     const token = tokenElement.defaultValue.toString();
     return headers.set('__RequestVerificationToken', token);
 }
开发者ID:thardy,项目名称:kazuku,代码行数:9,代码来源:http.service.ts

示例10: uploadFile

  uploadFile(data: FormData) {
    const headers = new HttpHeaders();
    headers.append('Content-Type', 'multipart/form-data');
    // 'application/x-www-form-urlencoded;charset=utf-8'
    headers.set('Accept', 'application/json');

    return new HttpRequest('POST', '/upload', data, {
        headers: headers,
        reportProgress: true,
    });
  }
开发者ID:domatskiy,项目名称:mediastorage.test,代码行数:11,代码来源:index.ts


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