import { EMPTY , Observable , catchError , filter , from , map , shareReplay , switchMap } from "rxjs" ; param url param options returns export function request ( url , options = { credentials : "same-origin" } ) { return from ( fetch ( `${ url }` , options ) ) . pipe ( filter ( res => res . status === 200 ) , catchError ( ( ) => EMPTY ) ) ; } template T param url param options returns export function requestJSON < T > ( url , options ? ) { return request ( url , options ) . pipe ( switchMap ( res => res . json ( ) ) , shareReplay ( 1 ) ) ; } param url param options returns export function requestXML ( url , options ? ) { const dom = new DOMParser ( ) ; return request ( url , options ) . pipe ( switchMap ( res => res . text ( ) ) , map ( res => dom . parseFromString ( res , "text/xml" ) ) , shareReplay ( 1 ) ) ; }