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


TypeScript Response.text方法代碼示例

本文整理匯總了TypeScript中angular2/http.Response.text方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Response.text方法的具體用法?TypeScript Response.text怎麽用?TypeScript Response.text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2/http.Response的用法示例。


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

示例1: DOMParser

 .map((res: Response) => {
     let dom = (new DOMParser()).parseFromString(res.text(), "text/xml");
     let json = xml2json(dom, "");
     let cert = "-----BEGIN CERTIFICATE-----" + JSON.parse(json).EntityDescriptor[0]["ds:Signature"]["KeyInfo"]["X509Data"]["X509Certificate"] + "-----END CERTIFICATE-----";
     let key = KEYUTIL.getKey(cert);
     return KJUR.jws.JWS.verifyJWT(token, key, { alg: ['RS256'] });
 })
開發者ID:AlexHiesch,項目名稱:dev,代碼行數:7,代碼來源:validation.service.ts

示例2: Array

            // Http Success
            (res:Response) => {

                if (res.status === 200) {
                    this.currentData = (res.text() !== '') ? res.json() : [{data: new Array(), group: new Array()}];
                }

            },
開發者ID:anonymous1983,項目名稱:ng2_dynamique_conception,代碼行數:8,代碼來源:statistic.component.ts

示例3: handleSignInResponse

    // handles the sign-in response.
    private handleSignInResponse(res: Response): Promise<WinkUser> {

        console.log("Sign in response status: " + res.status);

        if (res.status !== 200) {
            this.user.isSignedIn = false;
            console.log("Error: failed to sign in: \n" + res.text());
            return Promise.reject<WinkUser>(res);
        }
        else {
            this.user = JSON.parse(res.text());
            this.user.isSignedIn = true;

            console.log("Success: Signed in!");
            return Promise.resolve<WinkUser>(this.user);
        }
    }
開發者ID:HenryRawas,項目名稱:console,代碼行數:18,代碼來源:winkService.ts

示例4: handleError

 private handleError (error: Response) {
     console.error('http error');
     console.error(error);
     let errorText = error.text();
     if (error.status == 200) {
         errorText = 'The whole server is down. The connection has been refused.';
     }
     return Observable.throw(errorText || 'Server error');
 }
開發者ID:EnricoPicci,項目名稱:Sudoku-on-Angular2,代碼行數:9,代碼來源:messageRepositoryRest.service.ts

示例5: error

 error (res: Response) {
     let error;
     if (!(res instanceof Response)) {
         error = JSON.stringify(res);
     } else if (res.status >= 300) {
         error = 'Unexpected result.';
         if (res.status == 404) {
             error = res.text() || 'Resource not found';
         } else if (res.status == 400) {
             error = res.text() || 'Request could not be processed.';
         } else if (res.status == 401) {
             error = res.text() || 'Not authorized.';
         } else if (res.status == 403) {
             error = "You're not allowed to be here. Contact support for more information.";
         } else if (res.status == 500) {
             error = 'There was a problem with the server; try again later or contact support if the issue persists.';
         }
     }
     return Observable.throw(error);
 }
開發者ID:florinvoicuu,項目名稱:abc-frontend,代碼行數:20,代碼來源:utilities.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: 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

示例8: handleEnumerateDevicesResponse

    // handles the enumerate devices response.
    private handleEnumerateDevicesResponse(res: Response, idKeyFilter: string): Promise<WinkDevice[]> {

        console.log("Enumerate devices response status: " + res.status);

        if (res.status !== 200) {
            this.user.isSignedIn = false;
            console.log("Error: failed to enumerate devices: \n" + res.text());
            return Promise.reject<WinkDevice[]>(res);
        }
        else {

            let response: WinkDeviceEnumerationResponse = JSON.parse(res.text());

            // filter down to devices that have the specified ID Key filter
            // (e.g. light_bulb_id if we are looking for lightbulbs)
            this.devices = response.data.filter((WinkDevice) => {
                return !!WinkDevice[idKeyFilter];
            });

            console.log("Success: Devices enumerated");

            return Promise.resolve<WinkDevice[]>(this.devices);
        }
    }
開發者ID:HenryRawas,項目名稱:console,代碼行數:25,代碼來源:winkService.ts

示例9: handleError

	// TODO Change to handleError service
	private handleError(error: Response) {
		// in a real world app, we may send the error to some remote logging infrastructure
		// instead of just logging it to the console
		console.error(error);
		return Observable.throw(error.text() || 'Server error');
	}
開發者ID:zerbusdetroy,項目名稱:bank-client,代碼行數:7,代碼來源:login-state.service.ts

示例10:

 .then((res:Response) =>
 {
     console.log('\n'+res.text());
     this.regsuccess = true;
 });
開發者ID:Kuablaikan,項目名稱:Taskv3,代碼行數:5,代碼來源:reg.ts


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