In my express.js server I am doing this to forward a request to another server
async handleRequest(req, res) {
const serverUrl = "http://localhost:4000"
await req.pipe(request({ url: serverUrl + req.url })).pipe(res);
}
This is working as expected.
But I have decided to use axios or got library instead of request since request is no longer maintained.
But something like this is not working -
req.pipe(axios({url: serverUrl + req.url})).pipe(res);
I am getting error
(node:88124) UnhandledPromiseRejectionWarning: TypeError: dest.on is not a function
at IncomingMessage.Readable.pipe (internal/streams/readable.js:671:8)
How can I fix this? I want to forward the request as it is without making any changes in the request object.