node.js - javascript calling a function after getting https.request response (but not as its callback) -
beginner question. have following function makes https.request. when data arrives, passing callback function mydata
. (updated wording)
once mydata
updated then, want make call mycallback1
. ... but not inside function call response.on
can 1 please give me example on how this?
function test(mycallback1) { var myout = https.request(opts, function(response) { console.log("response is:", response); // don't want directly send mycallback1. // instead capture data in mydata response.on('data', mydata); }); // want call mycallback1 , give value of mydata. // how ensure mycallback() function executed // after // response.on('data', mydata) executed? };
the resonse.on
signature event, callback
event
event name , callback
callback function. work:
response.on('data', function(mydata) { // data mycallback1(); });
Comments
Post a Comment