當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。