如何从角度承诺中恢复身体?
如何从从角承诺中获得的反应中恢复身体。以下是输出。我想要第三个身体的数据,我不确定该如何重新计算。同样,我不确定为什么我会得到嵌套的诺言。请指教。
下面的代码:
fetch = () => {
debugger;
let url = `${environment.api}${Paths.FetchData}`+this.userId;
let req: HttpRequest<any> = new HttpRequest("Get", url, {
headers: new HttpHeaders({
"Accept": "text/html",
"Content-Type": "text/html"
}),
responseType: "json"
});
this.http.request(req).toPromise().then(r => {
debugger;
console.log(r);
return r;
});
}
后端代码:
@RequestMapping(value = "/fetchData/{userId}", method = RequestMethod.GET)
public String fetchData(@PathVariable("userId") String userId) {
System.out.println("calling00");
if (!MyUtility.checkNullOrZero(Long.valueOf(userId))) {
try {
return service.fetchData(Long.valueOf(userId));
} catch (Exception e) {
log.error("Error ", e);
return null;
}
}
return null;
}
How to return the body from the response received from an angular promise. Below is the output. I want the data from the third body which i am not sure how can i retreive. Again i am not sure why i am getting nested body for a promise. Please advise.
Below code :
fetch = () => {
debugger;
let url = `${environment.api}${Paths.FetchData}`+this.userId;
let req: HttpRequest<any> = new HttpRequest("Get", url, {
headers: new HttpHeaders({
"Accept": "text/html",
"Content-Type": "text/html"
}),
responseType: "json"
});
this.http.request(req).toPromise().then(r => {
debugger;
console.log(r);
return r;
});
}
Backend Code :
@RequestMapping(value = "/fetchData/{userId}", method = RequestMethod.GET)
public String fetchData(@PathVariable("userId") String userId) {
System.out.println("calling00");
if (!MyUtility.checkNullOrZero(Long.valueOf(userId))) {
try {
return service.fetchData(Long.valueOf(userId));
} catch (Exception e) {
log.error("Error ", e);
return null;
}
}
return null;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)