Can someone explain the difference between using
import { map } from 'rxjs/operators';
and import 'rxjs/add/operator/map';
?
This issue arises in my service method that handles user logins:
// import { map } from 'rxjs/operators'; // Causes runtime errors
import 'rxjs/add/operator/map'; // Works perfectly at runtime
public login(username: string, password: string): Observable<any> {
console.log('Sending login credentials to fetch a token');
const credentials = { 'email': username, 'password': password };
return this.httpService.postWithHeadersInResponse(URI_LOGIN, credentials)
.map((response: HttpResponse<any>) => {
const header = response.headers.get(this.authService.getHeaderName());
const token = this.authService.extractTokenFromHeader(header);
console.log('Token extracted from response header: ' + token);
this.authService.setJwtTokenToLocalStorage(token);
});
}