📜  在 Angular 8 中使用 promise - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:14.240000             🧑  作者: Mango

代码示例1
private fetchData(){
    const promise = this.httpClient.get(this.apiUrl).toPromise();
    console.log(promise);  
    promise.then((data)=>{
      console.log("Promise resolved with: " + JSON.stringify(data));
    }, (error)=>{
      console.log("Promise rejected with " + JSON.stringify(error));
    })
  }