Instantly share code, notes, and snippets.

Embed
What would you like to do?
Node.js callback example 2 - separate function instead of anonymous functions
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