-
-
Save DTrejo/792876 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function findBeer(words) { | |
//...code... | |
getResults(word, function(err, result){ | |
// now you can access things! | |
console.log(err, result); | |
}); | |
} | |
function getResults(word, callback) { | |
// ...code... | |
request({uri:db}, function (err, resp, b) { | |
if (err) throw err; | |
if (resp.statusCode !== 200) throw new Error("Could not get document. " + b ); | |
response = JSON.parse(b); | |
// important part! | |
callback(null, "this was a test"); | |
// unless there's no chance of an error, it's generally best to | |
// pass the error as first arg, and results as the rest of the arguments. | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment