superagent icon indicating copy to clipboard operation
superagent copied to clipboard

Can't use `request.on('error')` on plugins/middleware via `#.use()`

Open alexkvazos opened this issue 10 years ago • 2 comments

On my requests, I am attaching a common error handler with .use(errorHandler). I want to handle 401's and redirect to my login page.

My problem is that the error event handler is not being executed when an error occurs. If i console.log something on the errorHandler, it works, but if I do request.on('error', handler), the handler never gets called.

alexkvazos avatar Nov 19 '16 18:11 alexkvazos

In superagent 3 the error event works in more situations. Please test it.

kornelski avatar Nov 19 '16 22:11 kornelski

Oh okay thanks, I was using 2.3.0. I guess I can close the issue for now, because I am not using 3.x at the moment.

alexkvazos avatar Nov 20 '16 00:11 alexkvazos