当前位置: 首页>>代码示例>>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;未经允许,请勿转载。