你好,我需要得到张贴JSON对象,使用toPromise,其我的代码后,一些响应,响应未定义:获取后角2 toPromise HTTP
export class ApiStorage{
constructor(@Inject(Http) private http: Http){}
rs(){
this.http.post('http://0.0.0.0:80/student/outbound', this.json, headers)
.toPromise()
.then(response => {
respond = JSON.stringify(response);
return respond; //<- edited
})
.catch((error: any) => {
...
});
}
}
那么当在主要成分我用
send(){
respondJSON = apistorage.rs();
console.log(respondJSON);
}
respondJSON是不确定的
的[我如何返回从一个异步调用的响应?(可能的复制https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an - 异步呼叫) – echonax