Tuesday, July 19, 2016

Angular 2 RC4 RxJS Crash

Leave a Comment

I have a piece of code that worked perfectly until the latest Angular 2 update. Among other things, it uses Http requests & Observables.

I updated to RC4, import all RxJS operators (to make sure it works) and I get Error: SecurityError: DOM Exception 18

Any idea why and how I can fix this?

Simplified code snippet:

logIn(email: string, pass: string): Observable<boolean> {   return Observable.create((observer: Observer<boolean>) => {     let body = {       email: email,       pass: pass     };      this.http.post(this.origin + "/auth/logIn", JSON.stringify(body), this.requestArguments())       .subscribe((res: Response) => {         observer.next(res.json()["isLoggedIn"]);         observer.complete();       })   }) } 

Where

this.origin = window.location.origin + "/api" 

Weirdly:

Safari throws the exception

Chrome doesn't, but the page seems to get stuck

Firefox works properly.

And all of this is sporadic.. sometimes it works, sometimes it doesn't.

1 Answers

Answers 1

All angular RC versions depends on the same rxjs 5.0.0 beta 6, so I think you are looking at the wrong direction. your code though smells weired to me. http call inside a create function? your http response holds an observable, why do you try to create your own observable? if you need to map your object use map

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment