Harry
Harry

Reputation: 54979

expressjs automatically end with json?

I'm using expressjs to serve json.

If I try to res.end() with an object I get:

TypeError: first argument must be a string, Array, or Buffer

Is there a setting or a middleware that would automatically stringify before end or somehow make this work without putting json.stringify everywhere?

Thanks.

Upvotes: 0

Views: 733

Answers (1)

megakorre
megakorre

Reputation: 2223

if you are using express there is a send method witch stringify's it

Upvotes: 2

Related Questions