11 Web services

 

A faithful messenger

Hidden listing
function fetchAndLog(url) {
  fetch(url)
    .then(function(response) {
      // The response is a Response instance.
      // You parse the data into a useable format using `.json()`
      return response.json();
    }).then(function(data) {
// data is the parsed version of the JSON returned from the above endpoint
      console.log(); // Insert a new line for clarity sake
      console.log(data);
    });
}

This chapter covers

  • Representing a client request as a map
  • Representing a server response as a map
  • Passing data forward
  • Combining data from different sources

The architecture of modern information systems is made of software components written in various programming languages like JSON, which communicate over the wire by sending and receiving data represented in a language-independent data exchange format. DOP applies the same principle to the communication between inner parts of a program.

►Note

When a web browser sends a request to a web service, it’s quite common that the web service itself sends requests to other web services in order to fulfill the web browser request. One popular data exchange format is JSON.

11.1 Another feature request

11.2 Building the insides like the outsides

11.3 Representing a client request as a map

11.4 Representing a server response as a map

11.5 Passing information forward

11.6 Search result enrichment in action

Delivering on time

Summary