I am trying to send JSON via a 302 redirect. Is that possible in ExpressJS. The API states that a body can be added the res.json()
. For example:
res.json(302, {'name': 'larry'}).
On the receiving end (where the redirect goes too) the body is empty. Here is some sample code:
Sending App
app.get('/hello', function(req,res){
var data = {'name': 'larry'};
res.set('location', 'http://www.example.com/sending');
res.json(302, data);
});
Receiving App
app.get('/sending', function(req,res){
console.log('Body: ' + req.body)
res.send(req.body);
});
Note: the response headers for the 302 show a correct content-length of the data, but the receiving end shows an empty object.