外层都是:
new Promise(async (resolve, reject) => {
try {
// 方法1,2} catch (error) {
// 处理错误
Logger.error('Failed to fetch data from API.');
}
方法一(过时):
await this.httpService
.get(
'http://xxxxxxxxxxx',
).toPromise()
.then((v) => v.data);
方法二:
await this.httpService
.get(
'http://xxxxxxxxxxx',
).subscribe((x) => {
resolve(x.data);
});