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


TypeScript http.RequestOptions類代碼示例

本文整理匯總了TypeScript中@angular/http.RequestOptions的典型用法代碼示例。如果您正苦於以下問題:TypeScript RequestOptions類的具體用法?TypeScript RequestOptions怎麽用?TypeScript RequestOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: sendRequest

    private sendRequest(url: string, options: RequestOptionsArgs): Observable<string> {
        // make a copy
        let options1 = new RequestOptions();
        options1.method = options.method;
        options1 = options1.merge(options);
        let resource = this.adalService.GetResourceForEndpoint(url);
        let authenticatedCall: Observable<string>;
        if (resource) {
            if (this.adalService.userInfo.isAuthenticated) {
                authenticatedCall = this.adalService.acquireToken(resource)
                    .flatMap((token: string) => {
                        if (options1.headers == null) {
                            options1.headers = new Headers();
                        }
                        options1.headers.set('Authorization', 'Bearer ' + token);
                        return this.http.request(url, options1)
                            .catch(this.handleError);
                    });
            }
            else {
                authenticatedCall = Observable.throw(new Error('User Not Authenticated.'));
            }
        }
        else {
            authenticatedCall = this.http.request(url, options).map(this.extractData).catch(this.handleError);
        }

        return authenticatedCall;
    }
開發者ID:TimFST,項目名稱:ng2-adal,代碼行數:29,代碼來源:authHttp.service.ts

示例2: requestHelper

 private requestHelper(requestArgs: RequestOptionsArgs, additionalOptions?: RequestOptionsArgs): Observable<Response> {
   let options = new RequestOptions(requestArgs);
   if (additionalOptions) {
     options = options.merge(additionalOptions);
   }
   return this.request(new Request(options));
 }
開發者ID:penmark,項目名稱:mediat-frontend,代碼行數:7,代碼來源:http.service.ts

示例3: head

 /**
  * Get Head
  * @param endPoint
  * @param options
  * @returns {Observable<Response>}
  */
 public head(endPoint: string, options?: RequestOptions) : Observable<Response>{
     let _options:RequestOptions = ApiAuth.createHttpOptions();
     _options.url = Config.apiUrl + endPoint;
     _options.method = RequestMethod.Head;
     if (options) {
         _options = _options.merge(options);
     }
     return this.requestHelper(_options)
 }
開發者ID:luciancaetano,項目名稱:curly-app-base,代碼行數:15,代碼來源:auth.api.ts

示例4: patch

 /**
  * Patch a Resource
  * @param endPoint
  * @param body
  * @param options
  * @returns {Observable<Response>}
  */
 public patch(endPoint: string, body: any, options?: RequestOptions) : Observable<Response>{
     let _options:RequestOptions = ApiAuth.createHttpOptions();
     _options.url = Config.apiUrl + endPoint;
     _options.method = RequestMethod.Patch;
     _options.body = JSON.stringify(body);
     if (options) {
         _options = _options.merge(options);
     }
     return this.requestHelper(_options)
 }
開發者ID:luciancaetano,項目名稱:curly-app-base,代碼行數:17,代碼來源:auth.api.ts

示例5: find

 /**
  * Find a Resource
  * @param endPoint
  * @param params
  * @param additionalOptions
  * @returns {Observable<Response>}
  */
 public find(endPoint: string, params:URLSearchParams, options?:RequestOptions) : Observable<Response>{
     let _options:RequestOptions = ApiAuth.createHttpOptions();
     _options.url = Config.apiUrl + endPoint;
     _options.method = RequestMethod.Get;
     _options.search = params;
     if (options) {
         _options = _options.merge(options);
     }
     return this.requestHelper(_options);
 }
開發者ID:luciancaetano,項目名稱:curly-app-base,代碼行數:17,代碼來源:auth.api.ts

示例6: requestHelper

    private requestHelper(additionalOptions?:RequestOptions){
        this.loading.start(() => {

        });
        let options:RequestOptions = ApiAuth.createHttpOptions();
        if (additionalOptions) {
            options = options.merge(additionalOptions);
        }
        let req = this.http.request(new Request(options));
        req.subscribe(res => this.HandleReponse(res), error => this.HandleError(error));
        return req;
    }
開發者ID:luciancaetano,項目名稱:curly-app-base,代碼行數:12,代碼來源:auth.api.ts

示例7: mergeOptions

  private mergeOptions(options?: RequestOptionsArgs): RequestOptionsArgs {

    const csrfToken: string = this.cookieService.get('XSRF-TOKEN');

    let base: RequestOptions = new RequestOptions({
      headers: new Headers({
        'Content-Type': 'application/json',
        'X-Requested-With': 'XMLHttpRequest',
        'X-XSRF-TOKEN': csrfToken
      })
    });

    // If we have a valid jwt token, we add it
    if (this.tokenService.isValid()) {
      base.headers.set('Authorization', 'Bearer ' + this.tokenService.token.access_token);
    }

    return base.merge(options);
  }
開發者ID:brewday,項目名稱:waterprofile,代碼行數:19,代碼來源:api-http.ts

示例8: requestHelper

 private requestHelper(requestArgs: RequestOptionsArgs, additionalOptions?: RequestOptionsArgs): Observable<Response> {
     console.log("Handling options...");
     let options = new RequestOptions(requestArgs);
     if (additionalOptions) {
         options = options.merge(additionalOptions);
     }
     if (this.boxConfig.boxTokenCache) {
         return this.boxConfig.boxTokenCache.getToken()
             .mergeMap((token) => {
                 return this.requestWithToken(new Request(this.mergeOptions(options, this.defOpts)), token);
             })
     } else {
         return this.boxConfig.refreshTokenFunction()
             .mergeMap((token) => {
                 console.log("Refreshing token...");
                 console.log(token.json());
                 return this.requestWithToken(new Request(this.mergeOptions(options, this.defOpts)), token.json());
             });
     }
 }
開發者ID:box,項目名稱:samples,代碼行數:20,代碼來源:box-client.service.ts

示例9: _request

    _request(options: RequestOptionsArgs, auth?: boolean) {
        if (auth) {
            if (localStorage.getItem(this._config.tokenName)) {
                this.defaultOptions.headers.set('Authorization', 'Bearer ' + localStorage.getItem(this._config.tokenName))
            } else {

            }
        }
        options.url = `${this.API_ENDPOINT}${options.url}`
        return this.http.request(new Request(this.defaultOptions.merge(options)))
            .map((res: any) => res.json())
    }
開發者ID:iDevJS,項目名稱:idevjs-angular-client,代碼行數:12,代碼來源:api.ts

示例10: delete

 delete(url) {
     return this.http
         .delete(url, this.defaultOptions.merge({ url }))
         .map(ShHttpService.onResponseSuccess);
 }
開發者ID:garage-it,項目名稱:SmartHouse-frontend,代碼行數:5,代碼來源:sh-http.service.ts


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