running node.js proccess step by step : i was developer php, i try write code on node.js for pratice some program. i am confuse about node.js when i execute my program, line of code jumpt to next line


this is my part code

    //article.js    
    var article_model    = require('../models/article_model');
    var comment_model    = require('../models/comment_model');
    
    var list_article,list_comment;
    
    app.set('views','./views/article/');
    app.set('view engine','ejs'); 
    
    app.get('/list_article',csrfProtection,function(req,res){
    
     master_model.get_article(req,xparams,function(status,result,total_data){  
         list_article  = result.data;
        });
     console.log(list_article);
    
     master_model.get_comment(req,xparams,function(status,result,total_data){  
         list_comment  = result.data;
        });
    console.log(list_comment);
    
    var params = {  
                   title         : "Article List",
                   data_article       : list_article,
              
               };
               res.render('content.ejs',params);
    });

and then



    //master_model.js
    exports.get_article = function (req,hash, fn) {
    
        
         var auths = {
          user : api_server["auth_username"],
          pass : api_server["auth_password"],
        }
    
    
        request.get({url:"http://myapi.com/article/latest", auth:auths  } , function(err,httpResponse,body) {  
          if (!err && httpResponse.statusCode == 200) {
            var temp  = JSON.parse(body);
    
              if (temp.status == 1){
                result_data = {status:1, message : temp.message ,data : temp.data};
                return fn(true,result_data,1);
    
              }else if(temp.status == 0){
                result_data ={ status:0, message : temp.message};
                return fn(false,result_data,0);
              }
    
          }else{
            result_data ={ status:0, message : "error, please try again"};
            return fn(false,result_data,0); //something problem to API
          }
    
        })
         
       
    };
    
    exports.get_comment = function (req,hash, fn) {
    
        
         var auths = {
          user : api_server["auth_username"],
          pass : api_server["auth_password"],
        }
    
    
        request.get({url:"http://myapi.com/comment/latest", auth:auths  } , function(err,httpResponse,body) {  
          if (!err && httpResponse.statusCode == 200) {
            var temp  = JSON.parse(body);
    
              if (temp.status == 1){
                result_data = {status:1, message : temp.message ,data : temp.data};
                return fn(true,result_data,1);
    
              }else if(temp.status == 0){
                result_data ={ status:0, message : temp.message};
                return fn(false,result_data,0);
              }
    
          }else{
            result_data ={ status:0, message : "error, please try again"};
            return fn(false,result_data,0); //something problem to API
          }
    
        })
         
       
    };




when i run my code, and open browser, output data is blank, when i refresh again my browser show ouput my data (artcile list, and commment list)

and i look my console if first run

    output : {
    	 id : 1
    	 title : title 1..
    	 ...
    	 ..
    }
    undefined

if i refresh again my browser, all output complete to show (not show undefined)

my question
how to my code run process step by step until process end and deliver to views ?

any problem with my code?

thanks

