Chapter 8. Working with HTTP

 

This chapter covers

  • Examining the Fetch API browser
  • Looking at the Aurelia fetch client
  • Intercepting HTTP requests
  • Using the Aurelia HTTP client

In the real world, no SPA lives in isolation. SPAs are typically part of an ecosystem that involves a multitude of components, such as REST APIs and other dependencies, both internal to your application and external. The first Aurelia application I built integrated with a backend REST API to fetch application data and statistics, the Octopus Deploy REST API to retrieve a list of servers that we were interested in, and other APIs with information pertinent to the application. Integrating with these kinds of external dependencies brings your application to life.

With the growing popularity of serverless architectures, it’s increasingly common to host a simple SPA and use it to knit together a suite of external utilities—from cloud databases to SaaS (software as a service) offerings like Salesforce. The technology required to build these kinds of applications has existed for quite some time, starting with Microsoft’s invention of AJAX, back in 2000. The built-in browser API for working with AJAX, the XMLHttpRequest API, is beginning to show its age, and developers are starting to expect a cleaner and more modern HTTP browser API. Because of this, libraries like jQuery have created higher-level APIs to make it easier to work with HTTP requests in general, and AJAX specifically.

8.1. Overview of the Aurelia HTTP toolkit

8.2. Using aurelia-fetch-client

8.3. Working with aurelia-http-client

Summary