RxJS - ajax Operator



This operator will make an ajax request for the given url. To work with ajax we need to import it first as follows −

import { ajax } from 'rxjs/ajax';

Let us see an example to see the working of ajax in RxJS −

Example

import { map, retry } from 'rxjs/operators';
import { ajax } from 'rxjs/ajax';

let final_val = ajax('https://jsonplaceholder.typicode.com/users').pipe(map(e => e.response));
final_val.subscribe(x => console.log(x));

Output

Ajax Operator
Advertisements