node-rest-client
node-rest-client copied to clipboard
"res.setTimeout is not a function" when running in browser with Browserify
I couldn't find an answer to this in the readme. Do anyone know if this module is compatible with Browserify? I am trying to make a webapp, using a module i have written (https://www.npmjs.com/package/vegvesen). It fails and throws the error
TypeError: res.setTimeout is not a function. (In 'res.setTimeout(config.timeout, function(){
clientRequest.emit('responseTimeout',res);
res.close();
})', 'res.setTimeout' is undefined)
In my module I am doing the following call:
var args = {
headers: {
"Accept": "application/vnd.vegvesen.nvdb-v1+json",
"Content-Type": "application/vnd.vegvesen.nvdb-v1+json; charset=utf-8"
},
requestConfig: {
timeout: 1000,
noDelay: true,
keepAlive: true
},
responseConfig: {
timeout: 1000 //response timeout
}
};
client.get("https://www.vegvesen.no/nvdb/api/", args, function(data, response){
/*stuff*/
});
It works perfectly fine when running via node, this error only occurs in the browser, through Browserify.
I am not using Browserify, but I'm having the same issue: Uncaught TypeError: req.setTimeout is not a function
in the browser when using node-rest-client. Could really use a resolution as this is preventing me from even basic usage of this package.
I am just writing to bump this up. I have still not managed to solve this issue. I believe the error is caused by the "http" / "https" module used in the "protocol" module inside of node-rest-client.
Browserify claims that it is replacing calls to these native modules with browser comaptible versions.
Could we get some insight from some of the developers of this module?
Also related to an issue where the 'aborted' event is never emitted for a ClientRequest Item.