Example #1
0
 static get(url: string, headers: Object = null): Observable<any> {
     return Observable.ajax({
         url,
         method: 'GET',
         async: true,
         crossDomain: true,
         responseType: 'json',
         createXHR: () => new XMLHttpRequest()
     });
 } // get
Example #2
0
 static post(url: string, body: any, headers = { 'Content-Type': 'application/json' }): Observable<any> {
     return Observable.ajax({
         url,
         method: 'POST',
         body,
         headers,
         async: true,
         crossDomain: true,
         responseType: 'json',
         createXHR: () => new XMLHttpRequest()
     });
 } // post
const get = (url: string) => {
  return Observable
    .ajax(url)
    .map((resp: AjaxResponse) => resp.response);
};