In the nav.component.ts file, inject the AuthService into the constructor. We'll make it public here because we'll use it in the template.
Modify the login() method to use our AuthService.
We'll still log our result to the console (and also an error message) for testing purposes.
Testing the Login Method
We need to start up our .API project and our SPA project. Preferences may vary - you can decide between the built-in terminal in VS Code or using a separate terminal.
Navigate to your two projects and start up the servers
With your browser's console open, enter an actual username and password that you know is saved to your database.
You should get the logged in successfully message:
LoggedIn
Now, navigate to the network tab in your developer tools.
You should see the 200 Ok response.
post
If you're using Google Chrome - click on the Application tab and then Local Storage and verify that our token is being stored in the browser's storage:
Chrome:
localstorage
If you're using Firefox, click the Storage tab and then Local Storage: