doc: add comment to example about 2xx status codes

Fixes: https://github.com/nodejs/node/issues/29714

PR-URL: https://github.com/nodejs/node/pull/34223
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
James M Snell
2020-07-06 12:33:10 -07:00
parent 14ac6e4226
commit a720c0edcc

View File

@@ -2236,6 +2236,8 @@ http.get('http://nodejs.org/dist/index.json', (res) => {
const contentType = res.headers['content-type'];
let error;
// Any 2xx status code signals a successful response but
// here we're only checking for 200.
if (statusCode !== 200) {
error = new Error('Request Failed.\n' +
`Status Code: ${statusCode}`);