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


TypeScript Response.json方法代码示例

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


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

示例1: extractFeaturesData

 private extractFeaturesData (res: Response) {
   if (res.status < 200 || res.status >= 300) {
       throw new Error('Bad response status: ' + res.status);
   }
   let body = res.json();
   if (body) {
     return body;
   }
   return false;
 }
开发者ID:enridaga,项目名称:dinowolf,代码行数:10,代码来源:annotate.service.ts

示例2: extractData

 protected extractData(res : Response){
     console.log("entering extract data with response " + res.status);
     if (res.status < 200 || res.status >= 300){
         throw new Error('Bad response status ' + res.status);
     }
     console.log("got res 200, try to parse");
     
     let body = res.json();
     return body;
 }
开发者ID:felixsu,项目名称:raspi-2-angular-2,代码行数:10,代码来源:base-rest.service.ts

示例3:

 .map((res: Response) => {
     var categories = res.json().value;
     var categoryId: string;
     for (var i = 0; i < categories.length; i++) {
         if (categories[i].CategoryName === categoryName) {
             categoryId = categories[i].CategoryID;
         }
     }
     return categoryId;
 })
开发者ID:ScotHillier,项目名称:DevIntersections,代码行数:10,代码来源:product.service.ts

示例4: extractData

	private extractData(res: Response) {
		console.log(res);
		if (res.status < 200 || res.status >= 300) {
			throw new Error('Bad response status: ' + res.status);
		}
		let body = res.json();
		console.log(body);
		console.log(body.data);
		return body.data || {};
	}
开发者ID:arupadhy,项目名称:angular2-jquery-security,代码行数:10,代码来源:http.service.ts

示例5: _handleError

    private _handleError(response: Response) {
        let error = response.json()
        let message: string = 'Server Error'

        if (error.meta) {
            let meta: { status: number, message: string } = error.meta
            message = `${meta.status} ${meta.message}`
        }

        return Observable.throw(message)
    }
开发者ID:matheusmariano,项目名称:colonthree-webapp,代码行数:11,代码来源:http.service.ts

示例6:

        this.httpProvider.getRequest('/src/mocks/map.json').subscribe(// Http Success
            (res:Response) => {

                if (res.status === 200) {
                    if (res.text() !== '') {
                        this.map = res.json();
                        this.currentMap = this.map[0];
                        this.currentSubMap = {};
                    }
                }

            },
开发者ID:anonymous1983,项目名称:ng2_dynamique_conception,代码行数:12,代码来源:statistic.component.ts

示例7: extractAnnotationsData

 private extractAnnotationsData (res: Response) {
     if (res.status < 200 || res.status >= 300) {
         throw new Error('Bad response status: ' + res.status);
     }
     let body = res.json();
     let annotations: Annotations;
     if (body) {
         annotations = new Annotations(body);
     }
     return annotations;
 }
开发者ID:enridaga,项目名称:dinowolf,代码行数:11,代码来源:workflow-details.service.ts

示例8: tryParseErrorResponse

 tryParseErrorResponse(err:Response):any {
     let body:string = err.text();
     if(_.isEmpty(body)) {
         return body;
     }
     try {
         return err.json();
     } catch(e) {
         return body;
     }
 }
开发者ID:RGZINC,项目名称:swagger2-angular2-materialize,代码行数:11,代码来源:body-modal.ts

示例9: extractDatanode

  private extractDatanode (res: Response) {
      if (res.status < 200 || res.status >= 300) {
          throw new Error('Bad response status: ' + res.status);
      }
      let body = res.json();
      let o: Datanode;

      if (body) {
          o = new Datanode(body);
      }
      return o;
  }
开发者ID:enridaga,项目名称:dinowolf,代码行数:12,代码来源:datanode.service.ts

示例10: extractData

  private extractData (res: Response) {
      if (res.status < 200 || res.status >= 300) {
          throw new Error('Bad response status: ' + res.status);
      }
      let body = res.json();
      let o: Array<string>;

      if (body) {
          o = body;
      }
      return o;
  }
开发者ID:enridaga,项目名称:dinowolf,代码行数:12,代码来源:datanode.service.ts


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