forwardemail / forwardemail/superagent

Piping the response to a end file: get response status

Open
#469 5 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.