Skip to content

Commit

Permalink
doc: add comment to example about 2xx status codes
Browse files Browse the repository at this point in the history
Fixes: #29714

PR-URL: #34223
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
jasnell authored and addaleax committed Sep 22, 2020
1 parent f2f1537 commit fbb36ed
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,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}`);
Expand Down

0 comments on commit fbb36ed

Please sign in to comment.