23 Making HTTP Requests

 

This chapter covers

  • Using the built-in Angular features for HTTP requests
  • Receiving data from HTTP requests
  • Setting headers in HTTP requests
  • Handling HTTP request errors

All the examples since chapter 9 have relied on static data that has been hardwired into the application. In this chapter, I demonstrate how to use asynchronous HTTP requests, often called Ajax requests, to interact with a web service to get real data into an application. Table 23.1 puts HTTP requests in context.

23.1 Preparing the example project

23.1.1 Configuring the model feature module

23.1.2 Creating the data file

23.1.3 Running the example project

23.2 Understanding RESTful web services

23.3 Replacing the static data source

23.3.1 Creating the new data source service

23.3.2 Configuring the data source

23.3.3 Using the REST data source

23.3.4 Saving and deleting data

23.4 Consolidating HTTP requests

23.5 Making cross-origin requests

23.6 Configuring request headers

23.7 Handling errors

23.7.1 Generating user-ready messages

23.7.2 Handling the errors

23.8 Summary