I use express in my node App to send a JSON response:
App.get('/shops', function (req, res) {
res.json(200, {
success: true,
reason: 'data found correctly',
shops: shops
});
}
If in Chrome I go to 127.0.0.1:port/shops I see the response as a string (all in one line); is it possible to send the JSON answer formatted?
Before (with a less recent version of express) I was using something like
answer = JSON.stringify(answer, null, '\t'); // answer is a js object
res.send(200, answer);
But now (with express 4) even if I try something like that I see in the browser one row with many \n and \t inside of it;
Don't know if it is due to express version...