hi,
in express 3.x I did
res.contentType('application/json');
res.send(200, {
foo : 'bar'
});
return “pretty” JSON, in the browser and also in tools like Postman.
in express 4.x I do
res.set('Content-Type', 'application/json');
res.send(200, {
foo : 'bar'
});
and JSON is not formatted anymore.
Checked headers, content type header is set correctly.
Is there any way to return to the old formatted way?
thx
We turned it off by default. Just us a browser extension.
For anyone else looking at this, app.set(‘json spaces’, 2); is the configuration required to send pretty json.