response.statusCode
is a number, e.g. response.statusCode === 200
, not '200'
. As the error message says, write
expects a string
or Buffer
object, so you must convert it.
res.write(response.statusCode.toString());
You are also correct about your callback comment though. res.end();
should be inside the callback, just below your write
calls.