Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

LinkedIn Learning

Angular: API Communication and Authentication

via LinkedIn Learning

Overview

Discover how to use HTTP in Angular 2 applications to communicate with APIs and use JSON web tokens to authenticate users and requests.

APIs are at the heart of enterprise development, and Angular ships with robust services to communicate with them via HTTP. But one of the best ways to implement authentication of API services is using JWTs (JSON web tokens). In this course, we take a deep dive into using the provided $http service in Angular to create a robust and reusable API service implementing JWT authentication. Instructor Victor Mejia also covers how to use an Angular router to protect client-side routes and unit test services, HTTP requests, and async actions. All these concepts are demonstrated using a realistic contact management application, so you can see how API calls and user authentication are implemented in a real-world Angular app.

Syllabus

Introduction
  • Welcome
  • What you should know
  • Using exercise files
1. Getting Started
  • Overview of the Angular CLI
  • Architecture of an Angular + Node application
  • Database setup using mLab
  • Seeding a database
2. HTTP in Angular
  • GET route for the API
  • POST route for the API
  • Using @angular/http to retrieve contacts, part 1
  • Using @angular/http to retrieve contacts, part 2
  • Creating a new route for adding a new contact
  • Using ngForm for form submission
  • Writing the onSubmit() function
3. Creating an Angular Service for API Communication
  • API service with a central request function
  • Wrapper functions for GET, POST, PUT, and DELETE
  • Refactoring HTTP calls to use the API service
  • Central error catching
4. Adding JWT Authentication to the Node Express API
  • JWT (JSON Web Token) overview
  • Using Express Router
  • User login and generating JWTs
  • Authenticating requests and validating JWTs
5. UI Communication with the API and Authentication
  • Auth service for local JWT management
  • Implementing a user login
  • Sending JWTs to API requests
  • Logging out of the application
  • Preventing route access without authentication
Conclusion
  • Next steps

Taught by

Victor Mejia

Related Courses

Reviews

Start your review of Angular: API Communication and Authentication

Never Stop Learning!

Get personalized course recommendations, track subjects and courses with reminders, and more.

Sign up for free