node-xmlrpc icon indicating copy to clipboard operation
node-xmlrpc copied to clipboard

Uncaught TypeError: stream.setEncoding is not a function

Open iggi- opened this issue 9 years ago • 2 comments

I am trying to use this inside of a ReactJS framework, however I am presented with the error in the title. It is throwing an error on Line 46 of the deserializer.js file. https://github.com/baalexander/node-xmlrpc/blob/master/lib/deserializer.js#L46

Relevent ReactJS Code: `export default class ViewUsers extends React.Component { componentDidMount(){ var xmlrpc = require('xmlrpc');

var clientOps = {
        host: 'dev.example.com',
        port: 8443,
        path: '/dev/xmlrpc',
        basic_auth: {
            user: '[email protected]',
            pass: '123',
        }
};

var client = xmlrpc.createSecureClient(clientOps);
client.methodCall('view', ['3'], function (error, value) {
  if(error){
    console.log('error:', error);
    console.log('req headers:', error.req && error.req._header);
    console.log('res code:', error.res && error.res.statusCode);
    console.log('res body:', error.body);
  } else {
    console.log('value:', value);
  }
});

} } `

I just want to be able to get a successful call so I can display it in the render portion.

iggi- avatar Sep 16 '16 20:09 iggi-

I was able to get past this by commenting out the two references to the setEncoding since I could not find the function specified in the SAX library and SAX defaults to UTF-8 which is what I need.

iggi- avatar Sep 16 '16 22:09 iggi-

Same problem here at work with cordova + react. From what I can tell, response.setEncoding is available with nodejs but not with http-browserify

https://github.com/baalexander/node-xmlrpc/issues/135

drawm avatar Sep 23 '16 18:09 drawm