Skip to content

Commit 07e8778

Browse files
committed
Add response code checking to the solution to exercise 20.1
Issue marijnh#185
1 parent 2879c08 commit 07e8778

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

code/solutions/20_1_content_negotiation_again.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ function readStreamAsString(stream, callback) {
1919
path: "/author",
2020
headers: {Accept: type}
2121
}, function(response) {
22+
if (response.statusCode != 200) {
23+
console.error("Request for " + type + " failed: " + response.statusMessage);
24+
return;
25+
}
2226
readStreamAsString(response, function(error, content) {
2327
if (error) throw error;
2428
console.log("Type " + type + ": " + content);

0 commit comments

Comments
 (0)