Checking username if already used


#1

Hallo everybody, Just go ahead, I want to make a notification if the username has been used. This is my code.

Provide/user.ts

checkUsername(username: string) {
   username = username.toLowerCase()
   return this.db.object(`usernames/${username}`)
 }

Signup.ts

usernameAvailable: boolean;

checkUsername() {
 this.auth.checkUsername(this.displayName).subscribe(username => {
      this.usernameAvailable = !username.$value
    })
  }

Why does my code doesn’t work? Please help. Or you have a reference by using the angular & firebase