且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Angular 6中顺序执行http请求

更新时间:2023-11-30 10:40:22

如果您不熟悉rxjs,也许可以尝试以下方法?

If you are not familiar with rxjs, perhaps you can try the following?

let requests = listURL.map(url => new HttpRequest('PUT', url, formData, { reportProgress: true});

function do_seq(i) {
  httpClient.request(requests[i]).subscribe(event => {
   if (i < requests.length - 1) do_seq(i + 1);
  });
 }

do_seq(0);