Я хочу позвонить
login(username, password) {
return Parse.User.logIn(username, password)
.then(function (user) {
// store user details and jwt token in local storage to keep user logged in between page refreshes
localStorage.setItem('user', JSON.stringify(user));
console.log(user);
this.userSubject.next(user);
return user;
});
}
так же, как это
login(username, password) {
return this.http.post<user>(`${environment.apiUrl}/users/authenticate`, { username, password })
.pipe(map(user => {
// store user details and jwt token in local storage to keep user logged in between page refreshes
localStorage.setItem('user', JSON.stringify(user));
console.log(user);
this.userSubject.next(user);
return user;
}));
}
, но это приводит к ошибке
Uncaught (in promise): TypeError: Cannot read property 'userSubject' of undefined
TypeError: Cannot read property 'userSubject' of undefined