How can I get the 'return' value from alexa function?
I tried making a new function init() to wrap all the operation, but no luck. Not even error or something, and when I use
console.log(result.rank);
I receive the correct value in the console, without problems.
3
Code
rank: function() {
var a = document.createElement('a');
a.href = this.url;
var alexa = require('alexarank');
function init(){
alexa(a.hostname, function(error, result) {
if (!error) {
return result.rank;
} else {
console.log(error);
}
});
}
return init();