Created
July 9, 2013 23:29
-
-
Save jrm2k6/5962230 to your computer and use it in GitHub Desktop.
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
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