Categories
JavaScript Answers

How to fix the ‘first argument must be a string or Buffer – when using response.write with http.request’ with Node.js?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *