Angular 从onSearch()返回的承诺,onSearchButtonClick()被忽略

Angular 从onSearch()返回的承诺,onSearchButtonClick()被忽略,angular,Angular,我一直收到以下警告:从onSearch()返回的承诺被忽略,而从onSearchButtonClick()返回的承诺被忽略。我怎样才能修好它?我的代码如下: constructor( private unsplashService: UnsplashService ) {} async onSearch(event: KeyboardEvent) { if (event.key === "Enter") { return this.searchImage

我一直收到以下警告:
从onSearch()返回的承诺被忽略
,而从onSearchButtonClick()返回的承诺被忽略。我怎样才能修好它?我的代码如下:

  constructor(
    private unsplashService: UnsplashService
  ) {}

  async onSearch(event: KeyboardEvent) {
    if (event.key === "Enter") {
      return this.searchImages();
    }
  }

  async onSearchButtonClick() {
    return this.searchImages();
  }

  async searchImages() {
    if (!UtilService.isNullOrWhitespace(this.searchText)) {
      this.images = await this.unsplashService.searchImages(this.searchText);
    }
  }

  export class UnsplashService {
    getUnsplashApi(): Unsplash {
      return new Unsplash({
        accessKey: environment.unsplashAccessKey,
      })
   }

   async searchImages(query: String, pageIndex: number = 1, elementsPerPage: number = 30): Promise<any> {
     let response = await this.getUnsplashApi().search.photos(query, pageIndex, elementsPerPage);
     let json: any = await response.json();
     return await json.results;
  }
}
构造函数(
私人非租赁服务:非租赁服务
) {}
异步onSearch(事件:KeyboardEvent){
如果(event.key==“输入”){
返回此。searchImages();
}
}
异步onSearchButtonClick(){
返回此。searchImages();
}
异步搜索图像(){
如果(!UtilService.isNullOrWhitespace(this.searchText)){
this.images=等待this.unplashservice.searchImages(this.searchText);
}
}
出口类服务{
getUnsplashApi():Unsplash{
返回新的非Flash({
accessKey:environment.UnplashAccessKey,
})
}
异步searchImages(查询:字符串,页面索引:number=1,元素页面:number=30):承诺{
让response=wait this.getUnsplashApi().search.photos(查询、页面索引、elementsPerPage);
让json:any=wait response.json();
返回等待json.results;
}
}

从它们两个中删除async。异步声明包装承诺。。如果你已经回报了承诺,那么你就不需要它们了