The response object

Before we dive into the body, let's discuss about the response object. We can look at the response object by printing it to the screen. Let's swap out body in the console.log statement for response in the code:

const request = require('request');request({  url: 'https://maps.googleapis.com/maps/api/geocode/json?address=1301%20lombard%20street%20philadelphia',  json: true}, (error, response, body) => {  console.log(JSON.stringify(response, undefined, 2));});

Then save the file and rerun things inside of the Terminal by running the node app.js command. We'll get that little delay while we wait for the request to come back, and then we get a really complex object:

In the preceding screenshot, we can see the first thing we have ...

Get Learning Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.