【发布时间】:2021-10-08 12:43:17
【问题描述】:
我有一个带有param 的图片上传请求。我想将第一个请求的响应发送到 for 循环内的所有下一个请求。
for (let i = 0; i < e.target.files.length; i++) {
this.http.uploadImages(e.target.files[i], 'UploadImage', this.postId).subscribe((res:any)=>{
if(res.status == true){
this.postId = res.data.post_id; // i want to pass this postId to All other Requests.
this.userImages.push({ img: res.data });
}
})
}
【问题讨论】:
-
您不应该在第一个请求的订阅中发出任何其他请求。得到承诺并等待它
标签: javascript angular ajax for-loop file-upload