Piping the response to a end file: get response status
See original GitHub issueHow can I get response status if response is piped to file stream?
See code:
var client = supertest(...);
...
// Create writable stream
var writeStream = temp.createWriteStream();
temp.track();
// Superagent request
var req = client.get('/...');
req.on('end', function() {
// Here we can read file content
// It can contain actual file content
// Or JSON string representing error
// For example {'code': 'F-0001' , 'message': 'File not found'}
// We should parse this if response code != 200
// How can we get it here?
...
});
// Piping the response to a file
req.pipe(writeStream);
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Piping the response to a end file: get response status #469
How can I get response status if response is piped to file stream? See code: var client = supertest(...); ... // Create writable...
Read more >nodejs request module check for response status before pipe ...
I am currently using "request" module to download some files. The code looks like function download(url, fileName, path) { return ...
Read more >Developers - Piping the response to a end file: get response status -
Coming soon: A brand new website interface for an even better experience!
Read more >Streams, Piping, and Their Error Handling in Node.js - Medium
For an HTTP request, we created a read stream for a file and we piped it to the HTTP response write stream. In...
Read more >Invoke an AWS Lambda function in a pipeline in CodePipeline
On the status page for your pipeline, in the CodeDeploy action, choose Details. ... indexOf(search) > -1; } }; http.get(url, function(response) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try this:
I’ve tried this and the ‘response’ callback do not work with get requests.
I’m not sure if this is the ‘proper way’ to do this, but if you really need it, you can access the response status code in the ‘end’ callback doing
This breaks encapsulation, so be aware that it might change in future superagent versions.