Jquery request objects have a property by the name 'data' which is used to set form data and make a form request with the right headers.
I wanted to achieve the same in rxjs ajax but could not find a way. The only exhaustive list of request configuration properties I could find was this https://github.com/Reactive-Extensions/RxJS-DOM/blob/master/doc/operators/ajax.md
The documentation for RxJS5 is not complete yet on that part, but you can use it as follows:
import {Observable} from "rxjs/Observable";
import "rxjs/add/observable/dom/ajax";
const url = "http://my-site.org/some/endpoint";
const request$ = Observable.ajax.put(url, {a: "test"});
request$.subscribe(x => console.log(x));
And of course all other REST-methods are available
Observable.ajax(urlOrRequest: string | AjaxRequest): Observable<AjaxResponse>;
Observable.ajax.get(url: string, headers?: Object): Observable<AjaxResponse>;
Observable.ajax.post(url: string, body?: any, headers?: Object): Observable<AjaxResponse>;
Observable.ajax.put(url: string, body?: any, headers?: Object): Observable<AjaxResponse>;
Observable.ajax.patch(url: string, body?: any, headers?: Object): Observable<AjaxResponse>;
Observable.ajax.delete(url: string, headers?: Object): Observable<AjaxResponse>;
Observable.ajax.getJSON<T>(url: string, headers?: Object): Observable<T>;
If you want to send a fully custom ajax-request, you can use the following interface:
interface AjaxRequest {
url?: string;
body?: any;
user?: string;
async?: boolean;
method?: string;
headers?: Object;
timeout?: number;
password?: string;
hasContent?: boolean;
crossDomain?: boolean;
withCredentials?: boolean;
createXHR?: () => XMLHttpRequest;
progressSubscriber?: Subscriber<any>;
responseType?: string;
}
All take from here: https://github.com/ReactiveX/rxjs/blob/0ab1d3b4d1178a1d31c49c737832cde767da3fb1/src/observable/dom/AjaxObservable.ts