Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Node.js Development

You're reading from   Learning Node.js Development Learn the fundamentals of Node.js, and deploy and test Node.js applications on the web

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher Packt
ISBN-13 9781788395540
Length 658 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Andrew Mead Andrew Mead
Author Profile Icon Andrew Mead
Andrew Mead
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Set Up 2. Node Fundamentals – Part 1 FREE CHAPTER 3. Node Fundamentals – Part 2 4. Node Fundamentals – Part 3 5. Basics of Asynchronous Programming in Node.js 6. Callbacks in Asynchronous Programming 7. Promises in Asynchronous Programming 8. Web Servers in Node 9. Deploying Applications to Web 10. Testing the Node Applications – Part 1 11. Testing the Node Applications – Part 2 12. Another Book You May Enjoy

Making up of the HTTPS requests

The goal in the previous section was not to understand how HTTP works, or what exactly the arguments, error, response, and body are the goal was to come up with a real-world example of a callback, as opposed to the contrived examples that we've been using so far with setTimeout:

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(body, undefined, 2));
});

In the preceding case, we had a real callback that got fired once the HTTP request came back from the Google servers. We were able to print the body, and we saw exactly what we had in the website. In this section, we'll dive into these arguments, so let's kick things off by taking a look at the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime