Checking username if already used

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


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


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