Guest User

Untitled

a guest
Mar 20th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. checkAllowEmail(control: FormControl) {
  2. this.userService.getUserByEmail(control.value)
  3. .subscribe((user: UserDto) => {
  4. console.log(user);
  5. if (user !== undefined) {
  6. console.log(this.isAllowEmail);
  7. this.isAllowEmail = false;
  8. console.log(this.isAllowEmail);
  9. }
  10. });
  11. }
  12.  
  13. getUserByEmail(email: string): Observable<UserDto> {
  14. return this.http.get(`http://localhost:9092/api/v1/users?email=${email}`)
  15. .map((response: Response) => response.json())
  16. .map((user: UserDto) => user ? user : undefined);
  17. }
  18.  
  19. export class UserDto {
  20. constructor(
  21. public email: string,
  22. public name: string,
  23. public role: string
  24. ) {}
  25. }
  26.  
  27. {"name":"art","email":"art@mail.ru","role":"user"}
Add Comment
Please, Sign In to add comment