To fix the ‘first argument must be a string or Buffer – when using response.write with http.request’ with Node.js, we call write with a string or buffer.
For instance, we write
res.write(response.statusCode.toString());
to call write with the statusCode value converted to a string with toString to avoid the error.