當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。