function checkForData() {
        ph.windowProperty("DATA").then(function (data) {
            if (data !== undefined) {
                writeToFile(data);
                ph.exit();
            } else {
                setTimeout(checkForData, 100);
            }
        });
    }
function checkForData() {
        ph.windowProperty("DATA").then(function (data) {
            if (data !== undefined) {
                writeToFile(data);
                ph.exit();
            } else {
                setTimeout(checkForData, 100);
            }
        });
    }
function checkForData ( ) { ph . windowProperty ( "DATA" ) . then ( function ( data ) { if ( data !== undefined ) { writeToFile ( data ) ; ph . exit ( ) ; } else { setTimeout ( checkForData , 100 ) ; } } ) ; }
a hack suggested here: https://github.com/amir20/phantomjs-node/issues/292
a hack suggested here : https : // github . com / amir20 / phantomjs - node / issues / 292