Skip to content

Instantly share code, notes, and snippets.

@caseycesari
Created March 22, 2012 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caseycesari/2161913 to your computer and use it in GitHub Desktop.
Save caseycesari/2161913 to your computer and use it in GitHub Desktop.
https.get({
host: 'api.cloudmine.me',
headers: {'X-CloudMine-ApiKey': CM_KEY},
path: '/v1/app/' + CM_APP + '/text?keys=' + req.params.email
}, function(cmres) {
res.attachment('test.csv');
cmres.on('data', function(chunk) {
data += chunk;
// do some stuff to data
}).on('end', function() {
res.end(data,'utf8');
});
}).on('error', function(e) {
res.writeHead(500, {'Content-Type': 'application/json'});
res.end('{"error":"'+e+'"}');
});
@gsf
Copy link

gsf commented Mar 22, 2012

https.get({
    host: 'api.cloudmine.me',
    headers: {'X-CloudMine-ApiKey': CM_KEY},
    path: '/v1/app/' + CM_APP + '/text?keys=' + req.params.email
}, function(cmres) {
    res.attachment('test.csv');
    var data = '';
    cmres.on('data', function(chunk) {
        data += chunk;
    }).on('end', function() {
        // do some stuff to data
        res.end(data,'utf8');
    });
}).on('error', function(e) {
    res.writeHead(500, {'Content-Type': 'application/json'});
    res.end('{"error":"'+e+'"}');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment