import { Observable } from 'rxjs' ; import { XMLHttpRequest } from 'xmlhttprequest' ; import { AjaxResponse , ajax , AjaxRequest } from 'rxjs/ajax' ; export const createXHR = ( ) => new XMLHttpRequest ( ) ; export const buildGetRequest = ( url , token ) : AjaxRequest => ( { url , crossDomain : true , withCredentials : true , headers : { 'Content-Type' : 'application-json' , Authorization : `Bearer ${ token }` } , method : 'GET' , createXHR } ) ; export const ajaxGet = ( url , token ) : Observable < AjaxResponse > => ajax ( buildGetRequest ( url , token ) ) ;