本文整理匯總了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;
}
示例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;
}
示例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;
})
示例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 || {};
}
示例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)
}
示例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 = {};
}
}
},
示例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;
}
示例8: tryParseErrorResponse
tryParseErrorResponse(err:Response):any {
let body:string = err.text();
if(_.isEmpty(body)) {
return body;
}
try {
return err.json();
} catch(e) {
return body;
}
}
示例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;
}
示例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;
}