-1

Seems like it should be simple.

Trying:

res.status(500).send({ error: "That type already exists." })

Gets me:

TypeError: res.status is not a function

This is in sapper, not sure if that makes a diff.

mtyson
  • 8,196
  • 16
  • 66
  • 106

2 Answers2

1

Here's how it's done:

res.writeHead(500, {'Content-Type': 'text/plain'})
mtyson
  • 8,196
  • 16
  • 66
  • 106
0

According to the docs, you use res.statusCode = 500, or if you're throwing an error in a middleware, you'd use err.code = 500.

Zac Anger
  • 6,983
  • 2
  • 15
  • 42