1

I'm using request.js to download the content of a web page, but I need to wait until the dom is completely loaded before using it. Here is my code:

function requestPage(id) {
var options = {
    method: 'GET',
    gzip: true,
    url: 'xxx' + id,
    headers: getHeaders
}

request(options, function(error, response, body) {
    if (response.statusCode == 200) {
        generatePDF(generateHTML(body, id),id)
    }
})
}

How can I wait until everything is loaded before using the response in my generateHtml function?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • Possible duplicate: [wait-for-request-to-finish-node-js](http://stackoverflow.com/questions/30389764/wait-for-request-to-finish-node-js) – Clijsters Apr 27 '16 at 08:44
  • do you want to turn w website into a pdf? in case you do, check this out http://phantomjs.org/screen-capture.html – lipp Apr 27 '16 at 08:44
  • well I'm already using PhantomJS to convert to PDF. My probleme is the fetching part. – Faton Ramadani Apr 27 '16 at 14:04

0 Answers0