How to stream response from status code > 400 automatically? #1914
Unanswered
orkhanrustamli
asked this question in
Q&A
Replies: 1 comment
-
This has been asked almost an year ago, but since I found the answer, I’m leaving it here for future reference. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey everyone. I am beginner developer and I am trying to create simple public gateway which streams request to corresponding micro service.
request.get('http://localhost:${this.config.USERS_PORT}/users').pipe(res);
When I am doing stream with deprecated "request" library even if I am getting response with status code >=400, it still forwards the status code, body, headers to client.
However, when I try to do same with "got" by following way:
got.stream('http://localhost:${this.config.USERS_PORT}/users').pipe(res);
It throws an error and destroys the stream.
I think I can add
.on('error')
and do manual work but I wonder whether there is an easy way to do same as request is doing?Beta Was this translation helpful? Give feedback.
All reactions