我有一個(gè)接收配置文件數(shù)組的方法,我必須為每個(gè)配置文件進(jìn)行映射,并且在此地圖內(nèi)我必須再次映射到照片屬性中,其中包含用于請(qǐng)求 API 以獲取此圖片的圖片 ID。問題是,我在哪里可以安全地訪問此配置文件數(shù)組及其加載的每個(gè)配置文件的照片?profiles.map((profile, i) => { let photos = [] Promise.all(profile.photos.map(async idPhoto => { const res = await fetch(...) const img = await res.blob() photos.push(img) })) .then(() => profiles[i].photos = [...photos])})
另一個(gè)地圖調(diào)用中的異步 Array.map()
慕運(yùn)維8079593
2021-06-29 13:47:45