Sunday 21 May 2017

entire chunk of the site not getting in node js

my code: var url = URL.parse(flag?advSearchUrl:caseSearchUrl); var options = {"method":"POST","hostname": url.hostname,"port":null,"path": url.path,"headers":{"content-type":"application/x-www-form-urlencoded","cache-control":"no-cache"}} var req = http.request(options, function (res) { var chunks = []; // res.setEncoding('utf8');

          res.on('data', function (chunk) { chunks.push(chunk); });


          res.on('end', function () {
            // console.log(chunks)

            var body = Buffer.concat(chunks);
            // console.log(body.toString())
            return resolve(body.toString());
          });
          res.on('error', function(error){ return reject(error) });
        });
        // console.log(qs.stringify(payload))
        req.write(qs.stringify(payload));
        console.log(payload)
        // req.flushHeaders();
        req.end();
    })



via maria

No comments:

Post a Comment