# 3.5: Add Register Functionality

How did you do? We'll work through a solution here. Yours might be different and that's ok.

## Add Register Method to the AuthService

Open up the `auth.service.ts` class and add the following method:

```typescript
register(model: any) {
    return this._http.post(this.baseUrl + 'register', model, { headers: new HttpHeaders()
      .set('Content-Type', 'application/json')
    });
}
```

## Impement Register Method in the RegisterComponent

In the `register.component.ts` file, let's start by importing and injecting our `AuthService`:

```typescript
import { AuthService } from '../../services/auth.service';

// ...

    constructor(private _authService: AuthService) { }
```

Next, we'll use our `AuthService` in our `register()` method to make it functional:

```typescript
register() {
    this._authService.register(this.model).subscribe(() => {
        console.log('Registration successful!');
    }, error => {
        console.log(error);
    });
}
```

## Testing Registration

Make sure your `SPA` and `.API` servers are both running and open up your browser to port `4200`.

Try register with any username and password.

![RegistrationSuccess](https://122480229-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YfVcpLNVPaSQtyc%2F-LEoXBIjxiJ9_48lrXMp%2F-LEoXDXBWn5QyzWvz6Dz%2Fregistrationsuccess.png?generation=1528816005320028\&alt=media)

Open up SQL Server Management Studio and verify that your user was entered:

![DatabaseCheck](https://122480229-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YfVcpLNVPaSQtyc%2F-LEoXBIjxiJ9_48lrXMp%2F-LEoXDXDHhG4M2TqNMWH%2Fdatabasecheck.png?generation=1528816005680980\&alt=media)

This isn't perfect. We aren't validating on the client-side at all yet. But, we will come back and do this later.
