I am trying to make multiple AJAX request sequentially with some delay in each request. I would expect sequential response from each request. I have tried mergeMap rxjs operator. It works well but I want the response with some delay. Currently I am getting the response for each request sequentially but I need some delay in each response.
import { of, from, interval } from 'rxjs';
import { map, mergeMap } from 'rxjs/operators';
import { ajax } from 'rxjs/ajax';
const items = [1,2,3,4,5];
const requests = from(items)
.pipe(
mergeMap(item => ajax.getJSON(`https://api.github.com/users/${item}`)),
);
requests.subscribe(
data => console.log(data), //process item or push it to array
err => console.log(err)
);
Here is the stackbliz example.