I have an array of image objects.
console.info('gallery', galleryArray);
The length of this array can be different. I have to make a POST request on every item of this array. The next request must be executed only after previous request has finished.
So I tried to make an array of Observable requests like this:
let requests: Observable<Response>[] = [];
galleryArray.forEach((image) => {
requests.push(this._myService.uploadFilesImages(image));
});
console.info(requests);
My service looks like this:
uploadFilesImages(fileToUpload: any): Observable<any> {
const input = new FormData();
input.append('image', fileToUpload);
return this.uploadHttp.post(`${this.endpoint}`, input)
.map(
(res: Response) => res.json()
);
}
The question is how to perform those requests, so that every api call goes only after previous has finished? Help please. I'm new to Angular.


_myService.uploadFilesImagesreturn any promise or observable?