Guest User

Untitled

a guest
Oct 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import { Subject } from 'rxjs';
  2. import { ajax as rxAjax } from 'rxjs/ajax';
  3. import { merge } from 'rxjs/operators';
  4.  
  5. let form_data = new FormData();
  6. form_data.append( 'key', 'value' );
  7.  
  8. const progressSubscriber = new Subject();
  9. let request$ = rxAjax({
  10. url: 'http://localhost.com/some-api',
  11. method: 'POST',
  12. crossDomain: true,
  13. withCredentials: true,
  14. body: form_data,
  15. progressSubscriber
  16. });
  17.  
  18. progressSubscriber
  19. .pipe( merge(request$) )
  20. .subscribe( data =>{
  21.  
  22. if ( data.hasOwnProperty('status') ) {
  23. console.log('XHR is DONE');
  24. }
  25.  
  26. });
Add Comment
Please, Sign In to add comment