Created
October 8, 2018 16:28
-
-
Save andijakl/5339ed1b2262ec81513e60bea7fa7bfa to your computer and use it in GitHub Desktop.
Node.js callback example 2 - separate function instead of anonymous functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require("request"); | |
request("https://www.andreasjakl.com/", handleResponse); | |
function handleResponse(error, response, body) { | |
if (error) { | |
// Handle error | |
console.log("Error: ", error); | |
} else { | |
// Successful request | |
console.log("body: ", body); | |
} | |
} | |
console.log("Starting..."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment