O3 Framework / openmrsObservableFetch
openmrsObservableFetch<
T>(url,fetchInit):Observable<FetchResponse<T>>
Defined in: packages/framework/esm-api/src/openmrs-fetch.ts:279
The openmrsObservableFetch function is a wrapper around openmrsFetch that returns an Observable instead of a promise. It exists in case using an Observable is preferred or more convenient than a promise.
T
string
See [[openmrsFetch]]
FetchConfig = {}
See [[openmrsFetch]]
Observable<FetchResponse<T>>
An Observable that produces exactly one Response object. The response object is exactly the same as for [[openmrsFetch]].
import { openmrsObservableFetch } from '@openmrs/esm-api'
const subscription = openmrsObservableFetch(`${restBaseUrl}/session').subscribe(
response => console.log(response.data),
err => {throw err},
() => console.log('finished')
)
subscription.unsubscribe()
To cancel the network request, simply call subscription.unsubscribe();