尝试进行并行 API 调用,返回值未定义

问题描述 投票:0回答:0

下面的方法返回下面屏幕截图中的对象。有人可以帮助我理解为什么我会返回未定义的值吗?

 async creditsCall() {
    const credits: any[] = this.myForm.controls.credits.value

    const responses = await Promise.allSettled(
      credits.map(async credit => {
        const res = await fetch(
          'https://api.themoviedb.org/3/discover/movie?api_key=434577a472bbcc4c3d3154c77dd71ace&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=false&page=1&with_cast=' + credit + '&with_watch_monetization_types=flatrate'
        );
      })
    )

    console.log(responses)

  }

返回数组的屏幕截图。

javascript api asynchronous promise
© www.soinside.com 2019 - 2024. All rights reserved.