forwardemail / forwardemail/superagent
Piping the response to a end file: get response status
- Dominant language
- JavaScript
- Stars
- 16.6k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
How can I get response status if response is piped to file stream?
See code:
``` js
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);
```
Contributor guide
Assessment
This issue has not been assessed yet.