Chapter 8. Interacting with servers using HTTP and WebSockets

 

This chapter covers

  • Creating a simple web server using the Node and Express frameworks
  • Making server requests from Angular using the Http object API
  • Communicating with the Node server from Angular clients using the HTTP protocol
  • Wrapping a WebSocket client into an Angular service that generates an observable stream
  • Broadcasting data from the server to multiple clients via WebSockets

Angular applications can communicate with any web server supporting HTTP or WebSocket protocols, regardless of what server-side platform is used. So far, we’ve been covering mostly the client side of Angular applications, with the weather service example in chapter 5 being the only exception. In this chapter, you’ll learn how to communicate with web servers in more detail.

We’ll first give you a brief overview of Angular’s Http object, and then you’ll create a web server using TypeScript and Node.js. This server will provide the data required for all of the code samples, including the online auction. Then you’ll learn how the client code can make HTTP requests to web servers and consume the responses using observables, which we introduced in chapter 5. We’ll also show you how to communicate with the server via WebSockets, focusing on the server-side data push.

8.1. A brief overview of the Http object’s API

8.2. Creating a web server with Node and TypeScript

8.3. Bringing Angular and Node together

8.4. Client-server communication via WebSockets

8.5. Hands-on: implementing product search and bid notifications

8.6. Summary

sitemap