本文整理汇总了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;
}