node.js - How to set the location response HTTP header in Express framework? -
how set response location
http header in express? i've tried this, it's not working:
controller.prototype.create = function(prop, res) { var inst = new this.model(prop); inst.save(function(err) { if (err) { res.send(500, err); } res.location = '/customers/' + inst._id; res.send(201, null); }); };
this code persisting new document mongodb, , upon competition sets location , send 201
response. got response, no location
header set:
http/1.1 201 created x-powered-by: express content-length: 0 date: mon, 18 feb 2013 19:08:41 gmt connection: keep-alive
edit: uʍop ǝpısdn (cool nick btw) answer, res.setheader
works. why res.location
doesn't?
you're setting res.location
. res.location
function.
res.location('/customers/' + inst._id)
node.js http-headers express
No comments:
Post a Comment