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

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -