Skip to content

Instantly share code, notes, and snippets.

@arturovt
Last active May 21, 2019 18:58
Show Gist options
  • Save arturovt/74d4ac7de856222a1f101cebffb63e05 to your computer and use it in GitHub Desktop.
Save arturovt/74d4ac7de856222a1f101cebffb63e05 to your computer and use it in GitHub Desktop.
@Injectable({ providedIn: 'root' })
export class UserService {
private id = this.store.selectSnapshot<UserStateModel>(UserState).id;
constructor(private http: HttpClient, private store: Store) {}
public getUser() {
return this.http.get(`${environment.apiUrl}/users/${this.id}`);
}
public getLoginHistory() {
const id = this.getUserId();
return this.http.get(`${environment.apiUrl}/users/login-history/${id}`);
}
private getUserId() {
return this.store.selectSnapshot<UserStateModel>(UserState).id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment