0

How to make sequential (synchronous) http POST calls (wait the response from each call)

generateDoc(project, Item, language, isDOCXFormat) : Observable<any> {
        return this.http.post(this.sessionStorageService.retrieve('backendApi').baseUri + '/export/document/' + project.projectId + '/' + Item.id,
                     {language:language, isDOCXFormat:isPDFFormat}, option);
    }

Thank you.

Nico Van Belle
  • 4,911
  • 4
  • 32
  • 49
Debutantjsf
  • 109
  • 1
  • 5
  • 3
    Possible duplicate of [How to chain Http calls in Angular2](https://stackoverflow.com/questions/34104638/how-to-chain-http-calls-in-angular2) – Nico Van Belle Jul 07 '17 at 12:01

1 Answers1

2

If you want synchronous calls, you can use concatMap:

http.post(url1, data1).concatMap(t=> http.post(url2, data2);
Michael Kang
  • 52,003
  • 16
  • 103
  • 135