Hi folks,

I'm trying to mimic a code that I wrote in php. What the php does is parse 
GET data request, set the GET data in a cookie then finally redirect the 
client to another path of the same domain.

The problem  is the "redirect" is not working and I'm getting this message:

Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (http.js:689:11)
    at ServerResponse.res.set.res.header 
(/Users/neil/repos/acme/express/acmechartservice/node_modules/express/lib/response.js:524:10)
    at ServerResponse.res.contentType.res.type 
(/Users/neil/repos/acme/express/acmechartservice/node_modules/express/lib/response.js:391:15)
    at ServerResponse.res.send 
(/Users/neil/repos/acme/express/acmechartservice/node_modules/express/lib/response.js:109:43)
    at fn 
(/Users/neil/repos/acme/express/acmechartservice/node_modules/express/lib/response.js:773:10)
    at View.exports.renderFile [as engine] 
(/Users/neil/repos/acme/express/acmechartservice/node_modules/jade/lib/jade.js:294:12)
    at View.render 
(/Users/neil/repos/acme/express/acmechartservice/node_modules/express/lib/view.js:76:8)
    at Function.app.render 
(/Users/neil/repos/acme/express/acmechartservice/node_modules/express/lib/application.js:502:10)
    at ServerResponse.res.render 
(/Users/neil/repos/acme/express/acmechartservice/node_modules/express/lib/response.js:777:7)
    at Layer.module.exports [as handle] 
(/Users/neil/repos/acme/express/acmechartservice/app.js:78:9)

Here is the code

app.get('/sdm', function(req, res){
 
    var userData = {
        isAuthenticated  : true,
        username         : req.param('email'),
        resourceId       : req.param('userresourceid'),
        bearerToken      : req.param('token'),
        tokenResourceId  : req.param('tokenresourceid'),
        firstname        : req.param('fname'),
        lastname         : req.param('lname'),
        gravatarLink     : 'http://i.imgur.com/AVmo4I3.png',
        expirationDate   : '2014-12-31T00:00:00.000Z',
        locale           : 'en'
    };
 
    res.cookie('credentials', userData).send();
    res.redirect('http://localhost:3000/reloaded');
 
});

Any help would be greatly appreciated.

Thanks,

Neil

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/2891dc19-f620-4575-804a-b4768e98ece8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to