當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Headers.set方法代碼示例

本文整理匯總了TypeScript中angular2/http.Headers.set方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Headers.set方法的具體用法?TypeScript Headers.set怎麽用?TypeScript Headers.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2/http.Headers的用法示例。


在下文中一共展示了Headers.set方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: beforeEach

    beforeEach(() => {
      matcher = new RequestMatcher(res());
      headers = new Headers();

      headers.set('pass', '123');
      headers.set('passAgain', ['1', '2', '3']);
      request = req({ url: '', headers });
    });
開發者ID:laurelnaiad,項目名稱:respond-ng,代碼行數:8,代碼來源:request-matcher.spec.ts

示例2: RequestOptions

const mergeAuthToken = (options:RequestOptionsArgs) => {
  let newOptions = new RequestOptions({}).merge(options);
  let newHeaders = new Headers(newOptions.headers);
  newHeaders.set('x-auth-token', localStorage.getItem('jwt'));
  newHeaders.set('accept', 'application/json');
  newHeaders.set('content-type', 'application/json');
  newOptions.headers = newHeaders;
  return newOptions;
};
開發者ID:gtostock,項目名稱:angular2-app,代碼行數:9,代碼來源:Http.ts

示例3: RequestOptions

const mergeAuthToken = (options:RequestOptionsArgs) => {
  let newOptions = new RequestOptions({}).merge(options);
  let newHeaders = new Headers(newOptions.headers);
  let auth = JSON.parse(localStorage.getItem('auth'));
  if(auth!==null) {
      let access_token = auth.access_token;
      let token = auth.token_type+' '+ access_token;
      localStorage.setItem('token', token);
      newHeaders.set('Authorization', token);
      newHeaders.set('Accept', 'application/json');
      newHeaders.set('Content-Type', 'application/json');
  }
  newOptions.headers = newHeaders;
  return newOptions;
};
開發者ID:jiguan,項目名稱:mao_client,代碼行數:15,代碼來源:authHttp.ts

示例4: RequestOptions

const mergeAuthToken = (options:RequestOptionsArgs) => {
  let newOptions = new RequestOptions({}).merge(options);
  let newHeaders = new Headers(newOptions.headers);
  newHeaders.set('x-auth-token', localStorage.getItem('jwt'));
  newOptions.headers = newHeaders;
  return newOptions;
};
開發者ID:hollannikas,項目名稱:ssoidh-angular2,代碼行數:7,代碼來源:http-client.ts

示例5: save

 save(userModel:User){
     console.log('service called');
     var myHeaders:Headers = new Headers();
     myHeaders.set("content-type",'application/json');
     return this.http.post('/users',JSON.stringify(userModel),{
         headers:myHeaders
     });
 }
開發者ID:,項目名稱:,代碼行數:8,代碼來源:

示例6: auth

  auth(username: string, password: string): Observable<string> {
    let headers = new Headers();
    headers.set('Content-Type', 'application/json');
    let opts = new RequestOptions({ headers: headers });

    let body = JSON.stringify({ username: username, password: password });
    return this.http.post('http://localhost:8080/auth', body, opts)
      .map(res => res.json())
      .map(json => json.token);
  }
開發者ID:rune-catalog,項目名稱:Rune.Site,代碼行數:10,代碼來源:auth.service.ts

示例7: save

 save(flug: Flug) {
    
     var headers = new Headers();
     headers.set('Content-Type', 'text/json')
     
     var url = "http://www.angular.at/api/flug";
     
     return this.http
                 .post(url, JSON.stringify(flug),  {headers})
                 .map(resp => resp.json());
 }
開發者ID:HWelling,項目名稱:jax2016-workshop-mainz,代碼行數:11,代碼來源:flug.service.ts

示例8: findById

    findById(id: string) {
       
        var search = new URLSearchParams();
        search.set('flugNummer', id);
        
        var headers = new Headers();
        headers.set('Accept', 'text/json')
        
        var url = "http://www.angular.at/api/flug";
        
        return this.http
                    .get(url, {search, headers})
                    .map(resp => resp.json());

    }
開發者ID:HWelling,項目名稱:jax2016-workshop-mainz,代碼行數:15,代碼來源:flug.service.ts

示例9: getHeaders

    private getHeaders(useToken:boolean = true):Headers {
        let headers = new Headers({
            "Content-Type": "application/json",
            "X-Requested-With": "XMLHttpRequest",
        });

        if (useToken) {
            let token = Cookie.getCookie(CONSTANTS.CSRF_NAME);
            if (token) {
                headers.set("X-CSRFToken", token);
            }
        }

        return headers;
    }
開發者ID:adamski52,項目名稱:pet-project-client,代碼行數:15,代碼來源:api.ts


注:本文中的angular2/http.Headers.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。