score:1

you mean like a second argument, analog to getapi_data ?

function call_some_api(getdata){
    request('https://someurl..........',{json:true},(err,res,data) => {
        if (err) {
            console.log(err);
        }     
        if (res.statuscode === 200){
        
             var dataset = [];

             // btw this can be better/cleaner done with `.map` ;)
             data.foreach((value, key)=>{
             dataset.push(value.close);

            });                

           getdata(data, dataset);   
  
        }
    });
};

and in your render/http endpoint

app.get('/chart',function(req,res){
    call_some_api(function(getapi_data, dataset){
       
        res.render('chart',{
            datachart: getapi_data,
            dataset
        });

    });
});

note: code not tested, inline edited.


Related Query

More Query from same tag