Is it possible use "await" with Observables?

Hi,
is it possible to use “await” with Observables?

I have to call a web service and when the server sends a response I have to execute other actions.

I’m using HttpClient (get and post) that returns an Observable when used.

Is this correct?

const response = await this.httpClient.post(...)
<other actions after response has been received>

Thank you

cld

Use toPromise to convert an observable to a promise

https://www.learnrxjs.io/operators/utility/topromise.html

1 Like

Something like this?

await this.httpclient
.post()
.toPromise()

I’ll try. Thank you.

cld

Yes, that’s correct.