I have a NodeJS + Phantom project, and I have the following function:
function isLogged(page) {
    var logged = false;
    page.evaluate(function() {
        return document.querySelector(".login") != null;
    }, function(bl) {
        console.log("1");
        logged = bl;
    });
    console.log("2");
    return logged;
}
But this function prints "2" before "1". How can I fix it?
 
     
    