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


TypeScript Response.text方法代码示例

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


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

示例1: extractDataFilter

 private extractDataFilter(res: Response): Treeable[] {
     const treeables: Treeable[] = [];
     const obj = JSON.parse(res.text());
     const results: any[] = obj.entity.result;
     for (let i = 0; i < results.length; i++) {
         const r: any = results[i];
         let t: Treeable;
         if (r.type === 'folder') {
             t = Object.assign(new Folder(), r);
         } else if (r.type === 'file_asset') {
             t = Object.assign(new File(), r);
         }
         treeables[i] = t;
     }
     return treeables;
 }
开发者ID:dotCMS,项目名称:core-web,代码行数:16,代码来源:site-browser.service.ts

示例2: wrapError

export function wrapError(err: Response): Observable<WrappedError> {
  let wrappedError: WrappedError;
  try {
    wrappedError = {
      status: err.status,
      content: err.json()
    };
  } catch (jsonError) {
    wrappedError = {
      status: err.status,
      content: err.text() || jsonError.message
    };
  }
  console.warn(`${wrappedError.status}: ${(wrappedError.content && JSON.stringify(wrappedError.content) || '-')}`);
  return Observable.throw(wrappedError);
}
开发者ID:ouq77,项目名称:portfolio-web,代码行数:16,代码来源:wrap.error.ts

示例3: SecurityToken

            .map((res:Response) => {
                let securityToken:SecurityToken = new SecurityToken(
                    {
                    secretKey:res.headers.get(AppUtils.HEADER_X_SECRET),
                    token:res.headers.get(AppUtils.HEADER_X_TOKEN_ACCESS),
                    securityLevel:res.headers.get(AppUtils.HEADER_WWW_AUTHENTICATE)
                    }
                );

                localStorage.setItem(AppUtils.STORAGE_ACCOUNT_TOKEN,res.text());
                localStorage.setItem(AppUtils.STORAGE_SECURITY_TOKEN,JSON.stringify(securityToken));

                let account:Account = new Account(res.json());
                this.sendLoginSuccess(account);
                return account;
            });
开发者ID:fensminger,项目名称:SyncFiles,代码行数:16,代码来源:login.service.ts

示例4: getBody

 /**
  * Get the body returned in the response 
  * 
  * @private
  * @param {Response} response   http response
  * @returns {*}     null if no body, otherwise the body as an object
  */
 private getBody(response: Response): any {
     this.authService.authenticated(); // a successful API response received
     if (response.status === 204) {
         return null;
     }else {
         try {
             return response.json();
         }catch (e) {
             let text = response.text();
             if (text == null || text === '') {
                 return null;
             }else {
                 return text;
             }
         }
     }
 }
开发者ID:james-hu,项目名称:rtstatistics-web-mconsole,代码行数:24,代码来源:abstract-api.service.ts

示例5: handleError

  handleError(res: Response) {
    let text = 'Server error: ';
    text += res.text();
    let json = '';

    try {
      json = res.json();
    } catch (err) { ; }

    const error = {
      json,
      text
    };

    console.error(error);

    return Observable.throw(error);
  }
开发者ID:dadall,项目名称:PeerTube,代码行数:18,代码来源:rest-extractor.service.ts

示例6: handleError

  protected handleError(error: Response) {
    // In a real world app, we might use a remote logging infrastructure
    // We'd also dig deeper into the error to get a better message
    // let errMsg = (error.message) ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error';

    console.error(error); // log to console instead
    let status = error.status;
    switch (error.status) {
      case 500:
        let errMsg = error.text();
        this.delegateService.emitAlert(new AlertMessage(errMsg.toString(), ALERT_TYPE_DANGER));
        break;
      default:
        this.delegateService.emitAlert(new AlertMessage('System error', ALERT_TYPE_DANGER));
        break;
    }
    return Observable.throw(error);
  }
开发者ID:michalzeman,项目名称:angular2-training,代码行数:18,代码来源:base-entity.service.ts

示例7: parseResponse

    private parseResponse(res: Response) {
        console.log("response", res);

        let contentType = res.headers.get("Content-Type");
        if (contentType.indexOf("application/json") > -1) {
            return res.json();
        } else if (
            contentType.indexOf("application/xml") > -1 ||
            contentType.indexOf("text/xml") > -1) {
            var x2js = new X2JS();
            var text = res.text();
            var jsonObj: any = x2js.xml2js<any>(text);
            jsonObj = jsonObj[Object.keys(jsonObj)[0]];

            return jsonObj;
        }

        throw new Error("Unsupported response content type - " + contentType);
    }
开发者ID:qwb0920,项目名称:movieapp-ionic,代码行数:19,代码来源:base.service.ts

示例8: convertBooleanResponse

 /**
  * Convert response from text to boolean value;
  * @param res
  */
 static convertBooleanResponse(res: Response): boolean {
     return Boolean(res.text());
 }
开发者ID:howardyan93,项目名称:NgNode,代码行数:7,代码来源:rpc.ts

示例9:

 this.client.getAllExperimentsWithGET().subscribe((res:Response)=>{
   this.experiments = JSON.parse(res.text())['experiments'];
   this.filteredExperiments = this.experiments;
 },(err)=>{
开发者ID:CodingInfinity,项目名称:Benchmark-Web-Interface,代码行数:4,代码来源:view.all.experiment.component.ts

示例10: convertStringResponse

 /**
  * Convert string to string;
  * @param res
  */
 static convertStringResponse(res: Response):string {
     return res.text();
 }
开发者ID:howardyan93,项目名称:NgNode,代码行数:7,代码来源:rpc.ts


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