express - Newline at the end of REST API value responses? -
i implemented small rest api expressjs , once provided users (internal admin team) asked have additional newline @ end of each response.
in code:
var app = require('express')(); app.get('/thing/id1', function (req, res) { res.send('data1'); })
vs:
app.get('/thing/id2', function (req, res) { res.send("data2\n"); })
the background in case use api via curl
$ > curl -s http://localhost:3000/thing/id1 data1$ >
they want avoid echo
have nice output
$ > curl -s http://localhost:3000/thing/id1 ; echo data1 $ >
i hate additional newline in code , feels wrong send along, usecase.
so there argument, best practice or standard follow in regard?
cheers.
i agree @paulabbott – api should serve data, not presentation.
but try res.send("data2\n\r");
some prompts recognize \n
newline, , others \r
. https://stackoverflow.com/a/1761086/922593
Comments
Post a Comment