i am trying to make an HTTP proxy usng nodejitsu/node-http-proxy and i got this methods to catch proxied responses
proxy.on('proxyRes', function (proxyRes, req, res) {
var body = new Buffer('');
proxyRes.on('data', function (data) {
body = Buffer.concat([body, data]);
});
proxyRes.on('end', function () {
body = body.toString();
console.log("res from proxied server:", body);
});
});
here i able to get response but it is in buffer. so i tried many methods to convert my response to string format
but i got this instead
res from proxied server: �Ao�@���j/�Rc�I\���[ɡ�P�^O�m��hg������"�ĉ�J�i�y��g��K��y��%z�
�j:�J�5/�g]�B��
how to solve this issue
thanks in advance