Skip to content

Instantly share code, notes, and snippets.

@jrm2k6
Created July 9, 2013 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrm2k6/5962230 to your computer and use it in GitHub Desktop.
Save jrm2k6/5962230 to your computer and use it in GitHub Desktop.
var checkContentFromURL = function(contentFromUrl, checksfile) {
// t needs to be a function
var t = cheerioURLContent(contentFromUrl);
}
var cheerioURLContent = function(url) {
var t = rest.get(url).on("complete", function(result){
console.log(result);
});
console.log(typeof t);
return cheerio.load(t);
}
console.log is done after the return, so the results are not good.
How can I avoid this? I tried to use a callback this way:
var cheerioURLContent = function(url) {
var t = rest.get(url).on("complete", function(result){
callback(result);
});
}
var callback = function(result) {
return cheerio.load(result);
}
but it fails giving the following: Property '$' of object #<Object> is not a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment